Updated ApplicationDeployer to conditionally delete published application folder

This commit is contained in:
Kiran Challa 2016-08-08 15:08:20 -07:00
parent 5968a964c4
commit cc65ddfa28
2 changed files with 16 additions and 5 deletions

View File

@ -81,6 +81,8 @@ namespace Microsoft.AspNetCore.Server.Testing
/// </summary>
public bool PublishApplicationBeforeDeployment { get; set; }
public bool DeletePublishedApplicationOnDispose { get; set; } = true;
public ApplicationType ApplicationType { get; set; }
public string PublishedApplicationRootPath { get; set; }

View File

@ -82,14 +82,23 @@ namespace Microsoft.AspNetCore.Server.Testing
protected void CleanPublishedOutput()
{
try
if (DeploymentParameters.DeletePublishedApplicationOnDispose)
{
// We've originally published the application in a temp folder. We need to delete it.
Directory.Delete(DeploymentParameters.PublishedApplicationRootPath, true);
try
{
// We've originally published the application in a temp folder. We need to delete it.
Directory.Delete(DeploymentParameters.PublishedApplicationRootPath, true);
}
catch (Exception exception)
{
Logger.LogWarning($"Failed to delete directory : {exception.Message}");
}
}
catch (Exception exception)
else
{
Logger.LogWarning($"Failed to delete directory : {exception.Message}");
Logger.LogWarning(
"Skipping deleting the locally published folder as property " +
$"'{nameof(DeploymentParameters.DeletePublishedApplicationOnDispose)}' is set to 'false'.");
}
}