diff --git a/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs b/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs index b0b77079bb..5118c465b6 100644 --- a/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs +++ b/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentParameters.cs @@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Server.Testing /// /// Suggested base url for the deployed application. The final deployed url could be - /// different than this. Use for the + /// different than this. Use for the /// deployed url. /// public string ApplicationBaseUriHint { get; set; } @@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.Server.Testing public string SiteName { get; set; } - public string ApplicationPath { get; set; } + public string ApplicationPath { get; } public string TargetFramework { get; set; } @@ -95,9 +95,9 @@ namespace Microsoft.AspNetCore.Server.Testing { return string.Format( "[Variation] :: ServerType={0}, Runtime={1}, Arch={2}, BaseUrlHint={3}, Publish={4}", - ServerType, - RuntimeFlavor, - RuntimeArchitecture, + ServerType, + RuntimeFlavor, + RuntimeArchitecture, ApplicationBaseUriHint, PublishApplicationBeforeDeployment); } diff --git a/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentResult.cs b/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentResult.cs index b140cd0131..0125fb861d 100644 --- a/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentResult.cs +++ b/src/Microsoft.AspNetCore.Server.Testing/Common/DeploymentResult.cs @@ -16,10 +16,10 @@ namespace Microsoft.AspNetCore.Server.Testing public string ApplicationBaseUri { get; set; } /// - /// The web root folder where the application is hosted. This path can be different from the + /// The folder where the application is hosted. This path can be different from the /// original application source location if published before deployment. /// - public string WebRootLocation { get; set; } + public string ContentRoot { get; set; } /// /// Original deployment parameters used for this deployment. diff --git a/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs b/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs index bb0c61af77..781a07ecf6 100644 --- a/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.Testing/Deployers/ApplicationDeployer.cs @@ -76,12 +76,6 @@ namespace Microsoft.AspNetCore.Server.Testing throw new Exception($"{DotnetCommandName} publish exited with exit code : {hostProcess.ExitCode}"); } - DeploymentParameters.ApplicationPath = - (DeploymentParameters.ServerType == ServerType.IISExpress || - DeploymentParameters.ServerType == ServerType.IIS) ? - DeploymentParameters.PublishedApplicationRootPath : - DeploymentParameters.ApplicationPath; - Logger.LogInformation($"{DotnetCommandName} publish finished with exit code : {hostProcess.ExitCode}"); } diff --git a/src/Microsoft.AspNetCore.Server.Testing/Deployers/IISDeployer.cs b/src/Microsoft.AspNetCore.Server.Testing/Deployers/IISDeployer.cs index 48b0527f8f..0c5903d7e4 100644 --- a/src/Microsoft.AspNetCore.Server.Testing/Deployers/IISDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.Testing/Deployers/IISDeployer.cs @@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Server.Testing return new DeploymentResult { - WebRootLocation = DeploymentParameters.ApplicationPath, + ContentRoot = DeploymentParameters.PublishedApplicationRootPath, DeploymentParameters = DeploymentParameters, // Accomodate the vdir name. ApplicationBaseUri = uri.ToString(), diff --git a/src/Microsoft.AspNetCore.Server.Testing/Deployers/IISExpressDeployer.cs b/src/Microsoft.AspNetCore.Server.Testing/Deployers/IISExpressDeployer.cs index e983071941..c3d0540358 100644 --- a/src/Microsoft.AspNetCore.Server.Testing/Deployers/IISExpressDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.Testing/Deployers/IISExpressDeployer.cs @@ -34,13 +34,15 @@ namespace Microsoft.AspNetCore.Server.Testing DotnetPublish(); } + var contentRoot = DeploymentParameters.PublishApplicationBeforeDeployment ? DeploymentParameters.PublishedApplicationRootPath : DeploymentParameters.ApplicationPath; + var uri = TestUriHelper.BuildTestUri(DeploymentParameters.ApplicationBaseUriHint); // Launch the host process. - var hostExitToken = StartIISExpress(uri); + var hostExitToken = StartIISExpress(uri, contentRoot); return new DeploymentResult { - WebRootLocation = DeploymentParameters.ApplicationPath, + ContentRoot = contentRoot, DeploymentParameters = DeploymentParameters, // Right now this works only for urls like http://localhost:5001/. Does not work for http://localhost:5001/subpath. ApplicationBaseUri = uri.ToString(), @@ -48,7 +50,7 @@ namespace Microsoft.AspNetCore.Server.Testing }; } - private CancellationToken StartIISExpress(Uri uri) + private CancellationToken StartIISExpress(Uri uri, string contentRoot) { if (!string.IsNullOrWhiteSpace(DeploymentParameters.ServerConfigTemplateContent)) { @@ -57,7 +59,7 @@ namespace Microsoft.AspNetCore.Server.Testing DeploymentParameters.ServerConfigTemplateContent = DeploymentParameters.ServerConfigTemplateContent - .Replace("[ApplicationPhysicalPath]", DeploymentParameters.ApplicationPath) + .Replace("[ApplicationPhysicalPath]", contentRoot) .Replace("[PORT]", uri.Port.ToString()); DeploymentParameters.ServerConfigLocation = Path.GetTempFileName(); @@ -66,7 +68,7 @@ namespace Microsoft.AspNetCore.Server.Testing } var parameters = string.IsNullOrWhiteSpace(DeploymentParameters.ServerConfigLocation) ? - string.Format("/port:{0} /path:\"{1}\" /trace:error", uri.Port, DeploymentParameters.ApplicationPath) : + string.Format("/port:{0} /path:\"{1}\" /trace:error", uri.Port, contentRoot) : string.Format("/site:{0} /config:{1} /trace:error", DeploymentParameters.SiteName, DeploymentParameters.ServerConfigLocation); var iisExpressPath = GetIISExpressPath(); diff --git a/src/Microsoft.AspNetCore.Server.Testing/Deployers/NginxDeployer.cs b/src/Microsoft.AspNetCore.Server.Testing/Deployers/NginxDeployer.cs index 7353b65dd7..aa7070ff9b 100644 --- a/src/Microsoft.AspNetCore.Server.Testing/Deployers/NginxDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.Testing/Deployers/NginxDeployer.cs @@ -53,10 +53,10 @@ namespace Microsoft.AspNetCore.Server.Testing throw new InvalidOperationException("Deploy failed"); } } - + return new DeploymentResult { - WebRootLocation = DeploymentParameters.ApplicationPath, + ContentRoot = DeploymentParameters.ApplicationPath, DeploymentParameters = DeploymentParameters, ApplicationBaseUri = uri.ToString(), HostShutdownToken = exitToken diff --git a/src/Microsoft.AspNetCore.Server.Testing/Deployers/SelfHostDeployer.cs b/src/Microsoft.AspNetCore.Server.Testing/Deployers/SelfHostDeployer.cs index 169a641886..47353de788 100644 --- a/src/Microsoft.AspNetCore.Server.Testing/Deployers/SelfHostDeployer.cs +++ b/src/Microsoft.AspNetCore.Server.Testing/Deployers/SelfHostDeployer.cs @@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Server.Testing return new DeploymentResult { - WebRootLocation = DeploymentParameters.ApplicationPath, + ContentRoot = DeploymentParameters.PublishApplicationBeforeDeployment ? DeploymentParameters.PublishedApplicationRootPath : DeploymentParameters.ApplicationPath, DeploymentParameters = DeploymentParameters, ApplicationBaseUri = uri.ToString(), HostShutdownToken = hostExitToken