Make template package uninstallation detection report errors properly

This commit is contained in:
Steve Sanderson 2017-09-11 18:13:15 +01:00
parent cb500fe3b8
commit 148e4af837
1 changed files with 11 additions and 15 deletions

View File

@ -74,23 +74,19 @@ namespace Templates.Test.Helpers
// Verify we really did remove the previous templates
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("D"));
Directory.CreateDirectory(tempDir);
try
var proc = ProcessEx.Run(
output,
tempDir,
"dotnet",
$"new \"{templateName}\"");
proc.WaitForExit(assertSuccess: false);
if (!proc.Error.Contains($"No templates matched the input template name: {templateName}."))
{
var proc = ProcessEx.Run(
output,
tempDir,
"dotnet",
$"new \"{templateName}\"");
proc.WaitForExit(assertSuccess: false);
if (!proc.Error.Contains($"No templates matched the input template name: {templateName}."))
{
throw new InvalidOperationException($"Failed to uninstall previous templates. The template '{templateName}' could still be found.");
}
}
finally
{
Directory.Delete(tempDir);
throw new InvalidOperationException($"Failed to uninstall previous templates. The template '{templateName}' could still be found.");
}
Directory.Delete(tempDir);
}
private static string FindAncestorDirectoryContaining(string filename)