Fixed SelfHostDeployer and IISExpressDeployer to use the correct application path

This commit is contained in:
Kiran Challa 2016-06-06 14:16:46 -07:00
parent 772bd562c9
commit 808ee7e965
7 changed files with 18 additions and 22 deletions

View File

@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Server.Testing
/// <summary> /// <summary>
/// Suggested base url for the deployed application. The final deployed url could be /// Suggested base url for the deployed application. The final deployed url could be
/// different than this. Use <see cref="DeploymentResult.ApplicationBaseUri"/> for the /// different than this. Use <see cref="DeploymentResult.ApplicationBaseUri"/> for the
/// deployed url. /// deployed url.
/// </summary> /// </summary>
public string ApplicationBaseUriHint { get; set; } public string ApplicationBaseUriHint { get; set; }
@ -67,7 +67,7 @@ namespace Microsoft.AspNetCore.Server.Testing
public string SiteName { get; set; } public string SiteName { get; set; }
public string ApplicationPath { get; set; } public string ApplicationPath { get; }
public string TargetFramework { get; set; } public string TargetFramework { get; set; }
@ -95,9 +95,9 @@ namespace Microsoft.AspNetCore.Server.Testing
{ {
return string.Format( return string.Format(
"[Variation] :: ServerType={0}, Runtime={1}, Arch={2}, BaseUrlHint={3}, Publish={4}", "[Variation] :: ServerType={0}, Runtime={1}, Arch={2}, BaseUrlHint={3}, Publish={4}",
ServerType, ServerType,
RuntimeFlavor, RuntimeFlavor,
RuntimeArchitecture, RuntimeArchitecture,
ApplicationBaseUriHint, ApplicationBaseUriHint,
PublishApplicationBeforeDeployment); PublishApplicationBeforeDeployment);
} }

View File

@ -16,10 +16,10 @@ namespace Microsoft.AspNetCore.Server.Testing
public string ApplicationBaseUri { get; set; } public string ApplicationBaseUri { get; set; }
/// <summary> /// <summary>
/// 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. /// original application source location if published before deployment.
/// </summary> /// </summary>
public string WebRootLocation { get; set; } public string ContentRoot { get; set; }
/// <summary> /// <summary>
/// Original deployment parameters used for this deployment. /// Original deployment parameters used for this deployment.

View File

@ -76,12 +76,6 @@ namespace Microsoft.AspNetCore.Server.Testing
throw new Exception($"{DotnetCommandName} publish exited with exit code : {hostProcess.ExitCode}"); 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}"); Logger.LogInformation($"{DotnetCommandName} publish finished with exit code : {hostProcess.ExitCode}");
} }

View File

@ -56,7 +56,7 @@ namespace Microsoft.AspNetCore.Server.Testing
return new DeploymentResult return new DeploymentResult
{ {
WebRootLocation = DeploymentParameters.ApplicationPath, ContentRoot = DeploymentParameters.PublishedApplicationRootPath,
DeploymentParameters = DeploymentParameters, DeploymentParameters = DeploymentParameters,
// Accomodate the vdir name. // Accomodate the vdir name.
ApplicationBaseUri = uri.ToString(), ApplicationBaseUri = uri.ToString(),

View File

@ -34,13 +34,15 @@ namespace Microsoft.AspNetCore.Server.Testing
DotnetPublish(); DotnetPublish();
} }
var contentRoot = DeploymentParameters.PublishApplicationBeforeDeployment ? DeploymentParameters.PublishedApplicationRootPath : DeploymentParameters.ApplicationPath;
var uri = TestUriHelper.BuildTestUri(DeploymentParameters.ApplicationBaseUriHint); var uri = TestUriHelper.BuildTestUri(DeploymentParameters.ApplicationBaseUriHint);
// Launch the host process. // Launch the host process.
var hostExitToken = StartIISExpress(uri); var hostExitToken = StartIISExpress(uri, contentRoot);
return new DeploymentResult return new DeploymentResult
{ {
WebRootLocation = DeploymentParameters.ApplicationPath, ContentRoot = contentRoot,
DeploymentParameters = DeploymentParameters, DeploymentParameters = DeploymentParameters,
// Right now this works only for urls like http://localhost:5001/. Does not work for http://localhost:5001/subpath. // Right now this works only for urls like http://localhost:5001/. Does not work for http://localhost:5001/subpath.
ApplicationBaseUri = uri.ToString(), 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)) if (!string.IsNullOrWhiteSpace(DeploymentParameters.ServerConfigTemplateContent))
{ {
@ -57,7 +59,7 @@ namespace Microsoft.AspNetCore.Server.Testing
DeploymentParameters.ServerConfigTemplateContent = DeploymentParameters.ServerConfigTemplateContent =
DeploymentParameters.ServerConfigTemplateContent DeploymentParameters.ServerConfigTemplateContent
.Replace("[ApplicationPhysicalPath]", DeploymentParameters.ApplicationPath) .Replace("[ApplicationPhysicalPath]", contentRoot)
.Replace("[PORT]", uri.Port.ToString()); .Replace("[PORT]", uri.Port.ToString());
DeploymentParameters.ServerConfigLocation = Path.GetTempFileName(); DeploymentParameters.ServerConfigLocation = Path.GetTempFileName();
@ -66,7 +68,7 @@ namespace Microsoft.AspNetCore.Server.Testing
} }
var parameters = string.IsNullOrWhiteSpace(DeploymentParameters.ServerConfigLocation) ? 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); string.Format("/site:{0} /config:{1} /trace:error", DeploymentParameters.SiteName, DeploymentParameters.ServerConfigLocation);
var iisExpressPath = GetIISExpressPath(); var iisExpressPath = GetIISExpressPath();

View File

@ -53,10 +53,10 @@ namespace Microsoft.AspNetCore.Server.Testing
throw new InvalidOperationException("Deploy failed"); throw new InvalidOperationException("Deploy failed");
} }
} }
return new DeploymentResult return new DeploymentResult
{ {
WebRootLocation = DeploymentParameters.ApplicationPath, ContentRoot = DeploymentParameters.ApplicationPath,
DeploymentParameters = DeploymentParameters, DeploymentParameters = DeploymentParameters,
ApplicationBaseUri = uri.ToString(), ApplicationBaseUri = uri.ToString(),
HostShutdownToken = exitToken HostShutdownToken = exitToken

View File

@ -39,7 +39,7 @@ namespace Microsoft.AspNetCore.Server.Testing
return new DeploymentResult return new DeploymentResult
{ {
WebRootLocation = DeploymentParameters.ApplicationPath, ContentRoot = DeploymentParameters.PublishApplicationBeforeDeployment ? DeploymentParameters.PublishedApplicationRootPath : DeploymentParameters.ApplicationPath,
DeploymentParameters = DeploymentParameters, DeploymentParameters = DeploymentParameters,
ApplicationBaseUri = uri.ToString(), ApplicationBaseUri = uri.ToString(),
HostShutdownToken = hostExitToken HostShutdownToken = hostExitToken