Fix test logic for verifying template uninstallation. Now respects global.json for SDK selection.
This commit is contained in:
parent
0a077a21f8
commit
a067713a96
|
|
@ -73,21 +73,26 @@ namespace Templates.Test.Helpers
|
|||
private static void VerifyCannotFindTemplate(ITestOutputHelper output, string templateName)
|
||||
{
|
||||
// Verify we really did remove the previous templates
|
||||
var tempDir = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("D"));
|
||||
var tempDir = Path.Combine(Directory.GetCurrentDirectory(), Guid.NewGuid().ToString("D"));
|
||||
Directory.CreateDirectory(tempDir);
|
||||
|
||||
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}."))
|
||||
try
|
||||
{
|
||||
throw new InvalidOperationException($"Failed to uninstall previous templates. The template '{templateName}' could still be found.");
|
||||
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);
|
||||
}
|
||||
|
||||
Directory.Delete(tempDir);
|
||||
}
|
||||
|
||||
private static string FindAncestorDirectoryContaining(string filename)
|
||||
|
|
|
|||
Loading…
Reference in New Issue