Skip to content

Commit 148e4af

Browse files
Make template package uninstallation detection report errors properly
1 parent cb500fe commit 148e4af

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

test/Templates.Test/Helpers/TemplatePackageInstaller.cs

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,23 +74,19 @@ private static void VerifyCannotFindTemplate(ITestOutputHelper output, string te
7474
// Verify we really did remove the previous templates
7575
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("D"));
7676
Directory.CreateDirectory(tempDir);
77-
try
78-
{
79-
var proc = ProcessEx.Run(
80-
output,
81-
tempDir,
82-
"dotnet",
83-
$"new \"{templateName}\"");
84-
proc.WaitForExit(assertSuccess: false);
85-
if (!proc.Error.Contains($"No templates matched the input template name: {templateName}."))
86-
{
87-
throw new InvalidOperationException($"Failed to uninstall previous templates. The template '{templateName}' could still be found.");
88-
}
89-
}
90-
finally
77+
78+
var proc = ProcessEx.Run(
79+
output,
80+
tempDir,
81+
"dotnet",
82+
$"new \"{templateName}\"");
83+
proc.WaitForExit(assertSuccess: false);
84+
if (!proc.Error.Contains($"No templates matched the input template name: {templateName}."))
9185
{
92-
Directory.Delete(tempDir);
86+
throw new InvalidOperationException($"Failed to uninstall previous templates. The template '{templateName}' could still be found.");
9387
}
88+
89+
Directory.Delete(tempDir);
9490
}
9591

9692
private static string FindAncestorDirectoryContaining(string filename)

0 commit comments

Comments
 (0)