From 148e4af8376ed1a883b3c7e509d9a7c2be4257da Mon Sep 17 00:00:00 2001 From: Steve Sanderson Date: Mon, 11 Sep 2017 18:13:15 +0100 Subject: [PATCH] Make template package uninstallation detection report errors properly --- .../Helpers/TemplatePackageInstaller.cs | 26 ++++++++----------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/test/Templates.Test/Helpers/TemplatePackageInstaller.cs b/test/Templates.Test/Helpers/TemplatePackageInstaller.cs index ba272f156c..fd196eb3d3 100644 --- a/test/Templates.Test/Helpers/TemplatePackageInstaller.cs +++ b/test/Templates.Test/Helpers/TemplatePackageInstaller.cs @@ -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)