diff --git a/source/Calamari.Tests/Fixtures/Deployment/DeployWebPackageFixture.cs b/source/Calamari.Tests/Fixtures/Deployment/DeployWebPackageFixture.cs
index cca6c6796..0b231c308 100644
--- a/source/Calamari.Tests/Fixtures/Deployment/DeployWebPackageFixture.cs
+++ b/source/Calamari.Tests/Fixtures/Deployment/DeployWebPackageFixture.cs
@@ -192,7 +192,6 @@ public void ShouldExecuteFeatureScripts(DeploymentType deploymentType)
result.AssertOutput("Hello World!");
}
-#if IIS_SUPPORT
[Test]
[Category(TestCategory.CompatibleOS.OnlyWindows)]
public void ShouldModifyIisWebsiteRoot()
@@ -202,7 +201,7 @@ public void ShouldModifyIisWebsiteRoot()
// Create the website
var originalWebRootPath = Path.Combine(Path.GetTempPath(), "CalamariTestIisSite");
FileSystem.EnsureDirectoryExists(originalWebRootPath);
- var webServer = WebServerSupport.AutoDetect();
+ var webServer = new WebServerSevenSupport();
var siteName = "CalamariTest-" + Guid.NewGuid();
webServer.CreateWebSiteOrVirtualDirectory(siteName, "/", originalWebRootPath, 1081);
@@ -219,7 +218,6 @@ public void ShouldModifyIisWebsiteRoot()
webServer.DeleteWebSite(siteName);
FileSystem.DeleteDirectory(originalWebRootPath);
}
-#endif
[Test]
public void ShouldRunConfiguredScripts()
diff --git a/source/Calamari.Tests/Fixtures/Deployment/DeployWebPackageToIISFixture.cs b/source/Calamari.Tests/Fixtures/Deployment/DeployWebPackageToIISFixture.cs
index 2846a94e5..ccccadfd6 100644
--- a/source/Calamari.Tests/Fixtures/Deployment/DeployWebPackageToIISFixture.cs
+++ b/source/Calamari.Tests/Fixtures/Deployment/DeployWebPackageToIISFixture.cs
@@ -1,5 +1,4 @@
-#if IIS_SUPPORT
-using System;
+using System;
using System.IO;
using System.Linq;
using System.Security.AccessControl;
@@ -7,11 +6,12 @@
using System.Security.Principal;
using Calamari.Common.Plumbing.FileSystem;
using Calamari.Common.Plumbing.Variables;
-using Calamari.Deployment;
using Calamari.Integration.Iis;
using Calamari.Testing.Helpers;
using Calamari.Tests.Fixtures.Deployment.Packages;
+#if WINDOWS_CERTIFICATE_STORE_SUPPORT
using Calamari.Tests.Helpers.Certificates;
+#endif
using Microsoft.Web.Administration;
using NUnit.Framework;
using Polly;
@@ -629,5 +629,4 @@ private Application FindWebApplication(string websiteName, string virtualPath)
return GetWebSite(websiteName).Applications.Single(ap => ap.Path == virtualPath);
}
}
-}
-#endif
+}
\ No newline at end of file
diff --git a/source/Calamari.Tests/Fixtures/Iis/IisFixture.cs b/source/Calamari.Tests/Fixtures/Iis/IisFixture.cs
index d8f4ab06f..64d09d515 100644
--- a/source/Calamari.Tests/Fixtures/Iis/IisFixture.cs
+++ b/source/Calamari.Tests/Fixtures/Iis/IisFixture.cs
@@ -1,5 +1,4 @@
-#if IIS_SUPPORT
-using System;
+using System;
using Calamari.Integration.Iis;
using Calamari.Testing.Helpers;
using NUnit.Framework;
@@ -10,7 +9,7 @@ namespace Calamari.Tests.Fixtures.Iis
[Category(TestCategory.CompatibleOS.OnlyWindows)]
public class IisFixture
{
- readonly WebServerSupport webServer = WebServerSupport.AutoDetect();
+ readonly WebServerSupport webServer = new WebServerSevenSupport();
string siteName;
[SetUp]
@@ -61,5 +60,4 @@ public void TearDown()
webServer.DeleteWebSite(siteName);
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/source/Calamari/Calamari.csproj b/source/Calamari/Calamari.csproj
index eca113155..7bf920d37 100644
--- a/source/Calamari/Calamari.csproj
+++ b/source/Calamari/Calamari.csproj
@@ -46,6 +46,7 @@
all
runtime; build; native; contentfiles; analyzers; buildtransitive
+
diff --git a/source/Calamari/Commands/DeployPackageCommand.cs b/source/Calamari/Commands/DeployPackageCommand.cs
index a21bd75bf..1ed0d3dc1 100644
--- a/source/Calamari/Commands/DeployPackageCommand.cs
+++ b/source/Calamari/Commands/DeployPackageCommand.cs
@@ -89,10 +89,10 @@ public override int Execute(string[] commandLineArguments)
var configurationTransformer = ConfigurationTransformer.FromVariables(variables, log);
var transformFileLocator = new TransformFileLocator(fileSystem, log);
var embeddedResources = new AssemblyEmbeddedResources();
-#if IIS_SUPPORT
+
var iis = new InternetInformationServer();
featureClasses.AddRange(new IFeature[] { new IisWebSiteBeforeDeployFeature(windowsX509CertificateStore), new IisWebSiteAfterPostDeployFeature(windowsX509CertificateStore) });
-#endif
+
if (!CalamariEnvironment.IsRunningOnWindows)
{
featureClasses.Add(new NginxFeature(NginxServer.AutoDetect(), fileSystem));
@@ -118,9 +118,7 @@ public override int Execute(string[] commandLineArguments)
new PackagedScriptConvention(new DeployPackagedScriptBehaviour(log, fileSystem, scriptEngine, commandLineRunner)),
new ConfiguredScriptConvention(new DeployConfiguredScriptBehaviour(log, fileSystem, scriptEngine, commandLineRunner)),
new FeatureConvention(DeploymentStages.AfterDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources),
-#if IIS_SUPPORT
new LegacyIisWebSiteConvention(fileSystem, iis),
-#endif
new FeatureConvention(DeploymentStages.BeforePostDeploy, featureClasses, fileSystem, scriptEngine, commandLineRunner, embeddedResources),
new PackagedScriptConvention(new PostDeployPackagedScriptBehaviour(log, fileSystem, scriptEngine, commandLineRunner)),
new ConfiguredScriptConvention(new PostDeployConfiguredScriptBehaviour( log, fileSystem, scriptEngine, commandLineRunner)),
diff --git a/source/Calamari/Integration/Iis/InternetInformationServer.cs b/source/Calamari/Integration/Iis/InternetInformationServer.cs
index 62fdd83d2..738ba9358 100644
--- a/source/Calamari/Integration/Iis/InternetInformationServer.cs
+++ b/source/Calamari/Integration/Iis/InternetInformationServer.cs
@@ -1,5 +1,5 @@
-#if IIS_SUPPORT
-using System.Linq;
+using System.Linq;
+using Calamari.Common.Plumbing.Logging;
namespace Calamari.Integration.Iis
{
@@ -24,13 +24,14 @@ public bool OverwriteHomeDirectory(string iisWebSiteNameAndVirtualDirectory, str
var iisSiteName = parts.First();
var remainder = parts.Skip(1).Where(x => !string.IsNullOrWhiteSpace(x)).ToArray();
var virtualDirectory = remainder.Length > 0 ? string.Join("/", remainder) : null;
+ WebServerSupport server = new WebServerSevenSupport();
- var server = legacySupport
- ? WebServerSupport.Legacy()
- : WebServerSupport.AutoDetect();
-
+#if IIS_SUPPORT
+ if(legacySupport) {
+ server = new WebServerSixSupport();
+ }
+#endif
return server.ChangeHomeDirectory(iisSiteName, virtualDirectory, path);
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/source/Calamari/Integration/Iis/WebServerSevenSupport.cs b/source/Calamari/Integration/Iis/WebServerSevenSupport.cs
index c31504dbf..2b0125881 100644
--- a/source/Calamari/Integration/Iis/WebServerSevenSupport.cs
+++ b/source/Calamari/Integration/Iis/WebServerSevenSupport.cs
@@ -1,5 +1,4 @@
-#if IIS_SUPPORT
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Web.Administration;
@@ -8,8 +7,6 @@ namespace Calamari.Integration.Iis
{
public class WebServerSevenSupport : WebServerSupport
{
- const string Localhost = "localhost";
-
public override void CreateWebSiteOrVirtualDirectory(string webSiteName, string virtualDirectoryPath, string webRootPath, int port)
{
var virtualParts = (virtualDirectoryPath ?? String.Empty).Split('/', '\\').Select(x => x.Trim()).Where(x => x.Length > 0).ToArray();
@@ -155,7 +152,7 @@ public VirtualDirectory FindVirtualDirectory(string webSiteName, string virtualD
return virtualDirectory;
}
- public class VirtualDirectoryNode
+ class VirtualDirectoryNode
{
public string FullVirtualPath { get; set; }
public VirtualDirectory VirtualDirectory { get; set; }
@@ -172,7 +169,7 @@ public Site GetWebSite(string webSiteName)
return site;
}
- public Site FindWebSite(string webSiteName)
+ Site FindWebSite(string webSiteName)
{
return Execute(serverManager => serverManager.Sites.FirstOrDefault(x => String.Equals(x.Name, webSiteName, StringComparison.OrdinalIgnoreCase)));
}
@@ -193,7 +190,7 @@ public ApplicationPool GetApplicationPool(string applicationPoolName)
return applicationPool;
}
- public ApplicationPool FindApplicationPool(string applicationPoolName)
+ ApplicationPool FindApplicationPool(string applicationPoolName)
{
return Execute(serverManager => serverManager.ApplicationPools.FirstOrDefault(x => String.Equals(x.Name, applicationPoolName, StringComparison.OrdinalIgnoreCase)));
}
@@ -203,15 +200,15 @@ public bool ApplicationPoolExists(string applicationPool)
return FindApplicationPool(applicationPool) != null;
}
- private void Execute(Action action)
+ void Execute(Action action)
{
- using (var serverManager = ServerManager.OpenRemote(Localhost))
+ using (var serverManager = new ServerManager())
{
action(serverManager);
}
}
- private TResult Execute(Func func)
+ TResult Execute(Func func)
{
var result = default(TResult);
Action action = serverManager => result = func(serverManager);
@@ -219,5 +216,4 @@ private TResult Execute(Func func)
return result;
}
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/source/Calamari/Integration/Iis/WebServerSupport.cs b/source/Calamari/Integration/Iis/WebServerSupport.cs
index aa36e5618..4717d600c 100644
--- a/source/Calamari/Integration/Iis/WebServerSupport.cs
+++ b/source/Calamari/Integration/Iis/WebServerSupport.cs
@@ -1,5 +1,4 @@
-#if IIS_SUPPORT
-using System;
+using System;
namespace Calamari.Integration.Iis
{
@@ -9,27 +8,5 @@ public abstract class WebServerSupport
public abstract string GetHomeDirectory(string webSiteName, string virtualDirectoryPath);
public abstract void DeleteWebSite(string webSiteName);
public abstract bool ChangeHomeDirectory(string webSiteName, string virtualDirectoryPath, string newWebRootPath);
-
- public static WebServerSupport Legacy()
- {
- return new WebServerSixSupport();
- }
-
- public static WebServerSupport AutoDetect()
- {
- // Sources:
- // http://support.microsoft.com/kb/224609
- // http://msdn.microsoft.com/en-us/library/windows/desktop/ms724832(v=vs.85).aspx
-
-#pragma warning disable DE0009 // API is deprecated
- if (Environment.OSVersion.Version.Major < 6)
-#pragma warning restore DE0009 // API is deprecated
- {
- return new WebServerSixSupport();
- }
-
- return new WebServerSevenSupport();
- }
}
-}
-#endif
\ No newline at end of file
+}
\ No newline at end of file