From 6b667f53e555947dda830b11daa873119e9562d9 Mon Sep 17 00:00:00 2001 From: NansenViktor Date: Wed, 27 Mar 2013 15:29:01 +0100 Subject: [PATCH] Added support to install the current directory --- src/Wia/Commands/WebsiteContext.cs | 6 ++++- src/Wia/Resolver/ContextResolver.cs | 38 ++++++++++++++++------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/src/Wia/Commands/WebsiteContext.cs b/src/Wia/Commands/WebsiteContext.cs index 421b700..a65b44c 100644 --- a/src/Wia/Commands/WebsiteContext.cs +++ b/src/Wia/Commands/WebsiteContext.cs @@ -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() { diff --git a/src/Wia/Resolver/ContextResolver.cs b/src/Wia/Resolver/ContextResolver.cs index 9e8b823..de01f8a 100644 --- a/src/Wia/Resolver/ContextResolver.cs +++ b/src/Wia/Resolver/ContextResolver.cs @@ -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)) {