Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1 from NansenViktor/master
Browse files Browse the repository at this point in the history
Support for install within web project directory
  • Loading branch information
Andreas committed Mar 27, 2013
2 parents 48c8c8e + 6b667f5 commit bab1d70
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 18 deletions.
6 changes: 5 additions & 1 deletion src/Wia/Commands/WebsiteContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ public WebsiteContext() {
public bool ExitAtNextCheck { get; set; }

public string GetWebProjectDirectory() {
return Path.Combine(CurrentDirectory, WebProjectName);
if(WebProjectName==".") {
return CurrentDirectory;
} else {
return Path.Combine(CurrentDirectory, WebProjectName);
}
}

public bool HasAdministratorPrivileges() {
Expand Down
38 changes: 21 additions & 17 deletions src/Wia/Resolver/ContextResolver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,30 @@ private static string GetWebProjectName(WebsiteContext context) {

string webProjectName = context.WebProjectName;
if (string.IsNullOrWhiteSpace(webProjectName)) {
var webDirectories = Directory.EnumerateDirectories(context.CurrentDirectory)
.Where(dir => Path.GetFileName(dir).Contains("Web", StringComparison.OrdinalIgnoreCase))
.ToList();

if (!webDirectories.Any()) {
context.ExitAtNextCheck = true;
Console.WriteLine("Web project could not be resolved. Please specifiy using \"--webproject Project.Web\". \n");
return null;
if (Directory.GetFiles(context.CurrentDirectory).Any(item => item.ToLower().EndsWith("\\web.config"))) {
webProjectName = ".";
}

if (webDirectories.Count > 1) {
context.ExitAtNextCheck = true;
Console.WriteLine("You need to specificy which web project to use: \n--webproject " +
webDirectories.Select(path => Path.GetFileName(path)).Aggregate((a, b) => a + "\n--webproject " + b) + "\n");
return null;
else{
var webDirectories = Directory.EnumerateDirectories(context.CurrentDirectory)
.Where(dir => Path.GetFileName(dir).Contains("Web", StringComparison.OrdinalIgnoreCase))
.ToList();

if (!webDirectories.Any()) {
context.ExitAtNextCheck = true;
Console.WriteLine("Web project could not be resolved. Please specifiy using \"--webproject Project.Web\". \n");
return null;
}

if (webDirectories.Count > 1) {
context.ExitAtNextCheck = true;
Console.WriteLine("You need to specificy which web project to use: \n--webproject " +
webDirectories.Select(path => Path.GetFileName(path)).Aggregate((a, b) => a + "\n--webproject " + b) + "\n");
return null;
}

webProjectName = Path.GetFileName(webDirectories.FirstOrDefault());
}

webProjectName = Path.GetFileName(webDirectories.FirstOrDefault());
}

var projectDirectory = Path.Combine(context.CurrentDirectory, webProjectName);

if (!Directory.Exists(projectDirectory)) {
Expand Down

0 comments on commit bab1d70

Please sign in to comment.