Fixed SelfHostDeployer and IISExpressDeployer to use the correct application path
This commit is contained in:
parent
772bd562c9
commit
808ee7e965
|
|
@ -54,7 +54,7 @@ namespace Microsoft.AspNetCore.Server.Testing
|
|||
|
||||
/// <summary>
|
||||
/// 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.
|
||||
/// </summary>
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,10 +16,10 @@ namespace Microsoft.AspNetCore.Server.Testing
|
|||
public string ApplicationBaseUri { get; set; }
|
||||
|
||||
/// <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.
|
||||
/// </summary>
|
||||
public string WebRootLocation { get; set; }
|
||||
public string ContentRoot { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Original deployment parameters used for this deployment.
|
||||
|
|
|
|||
|
|
@ -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}");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue