From f8fbb15e14cea45f7f6b1d8b15ecf545276cfa9a Mon Sep 17 00:00:00 2001 From: Chris R Date: Thu, 10 Nov 2016 16:06:39 -0800 Subject: [PATCH] IISIntegration#292 Test support for bin deployed aspnetcore.dll --- .../Deployers/IISExpressDeployer.cs | 41 ++++++++++++++++++- .../project.json | 6 ++- 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting/Deployers/IISExpressDeployer.cs b/src/Microsoft.AspNetCore.Server.IntegrationTesting/Deployers/IISExpressDeployer.cs index 9bd70e4d21..60df37fae0 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting/Deployers/IISExpressDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting/Deployers/IISExpressDeployer.cs @@ -5,8 +5,9 @@ using System; using System.Diagnostics; using System.IO; using System.Threading; -using Microsoft.Extensions.Logging; using Microsoft.AspNetCore.Server.IntegrationTesting.Common; +using Microsoft.Extensions.Internal; +using Microsoft.Extensions.Logging; namespace Microsoft.AspNetCore.Server.IntegrationTesting { @@ -22,6 +23,16 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting { } + public bool IsWin8OrLater + { + get + { + var win8Version = new Version(6, 2); + + return (new Version(RuntimeEnvironment.OperatingSystemVersion) >= win8Version); + } + } + public override DeploymentResult Deploy() { // Start timer @@ -57,6 +68,34 @@ namespace Microsoft.AspNetCore.Server.IntegrationTesting // Pass on the applicationhost.config to iis express. With this don't need to pass in the /path /port switches as they are in the applicationHost.config // We take a copy of the original specified applicationHost.Config to prevent modifying the one in the repo. + if (DeploymentParameters.ServerConfigTemplateContent.Contains("[ANCMPath]")) + { + string ancmPath; + if (!IsWin8OrLater) + { + // The nupkg build of ANCM does not support Win7. https://github.com/aspnet/AspNetCoreModule/issues/40. + ancmPath = @"%ProgramFiles%\IIS Express\aspnetcore.dll"; + } + // Bin deployed by Microsoft.AspNetCore.AspNetCoreModule.nupkg + else if (DeploymentParameters.RuntimeFlavor == RuntimeFlavor.CoreClr + && DeploymentParameters.ApplicationType == ApplicationType.Portable) + { + ancmPath = Path.Combine(contentRoot, @"runtimes\win7-x64\native\aspnetcore.dll"); + } + else + { + ancmPath = Path.Combine(contentRoot, "aspnetcore.dll"); + } + + if (!File.Exists(ancmPath)) + { + throw new FileNotFoundException("AspNetCoreModule could not be found.", ancmPath); + } + + DeploymentParameters.ServerConfigTemplateContent = + DeploymentParameters.ServerConfigTemplateContent.Replace("[ANCMPath]", ancmPath); + } + DeploymentParameters.ServerConfigTemplateContent = DeploymentParameters.ServerConfigTemplateContent .Replace("[ApplicationPhysicalPath]", contentRoot) diff --git a/src/Microsoft.AspNetCore.Server.IntegrationTesting/project.json b/src/Microsoft.AspNetCore.Server.IntegrationTesting/project.json index a7e2cb5ed1..0d27f18584 100644 --- a/src/Microsoft.AspNetCore.Server.IntegrationTesting/project.json +++ b/src/Microsoft.AspNetCore.Server.IntegrationTesting/project.json @@ -28,11 +28,15 @@ "Microsoft.AspNetCore.Testing": "1.1.0-*", "Microsoft.Extensions.FileProviders.Embedded": "1.1.0-*", "Microsoft.Extensions.Logging.Abstractions": "1.1.0-*", + "Microsoft.Extensions.PlatformAbstractions": "1.1.0-*", "Microsoft.Extensions.Process.Sources": { "type": "build", "version": "1.1.0-*" }, - "Microsoft.Extensions.PlatformAbstractions": "1.1.0-*", + "Microsoft.Extensions.RuntimeEnvironment.Sources": { + "type": "build", + "version": "1.1.0-*" + }, "NETStandard.Library": "1.6.1-*" }, "frameworks": {