Skip to content

Commit c486a4b

Browse files
authored
Re-use the dotnet-new lock during template package installation (#22007)
1 parent b16a39f commit c486a4b

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

src/ProjectTemplates/Shared/TemplatePackageInstaller.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@
66
using System.IO;
77
using System.Linq;
88
using System.Reflection;
9-
using System.Threading;
109
using System.Threading.Tasks;
1110
using Microsoft.AspNetCore.Internal;
12-
using Microsoft.AspNetCore.Testing;
1311
using Microsoft.Extensions.CommandLineUtils;
1412
using Xunit;
1513
using Xunit.Abstractions;
@@ -18,7 +16,6 @@ namespace Templates.Test.Helpers
1816
{
1917
internal static class TemplatePackageInstaller
2018
{
21-
private static readonly SemaphoreSlim InstallerLock = new SemaphoreSlim(1);
2219
private static bool _haveReinstalledTemplatePackages;
2320

2421
private static readonly string[] _templatePackages = new[]
@@ -52,7 +49,7 @@ internal static class TemplatePackageInstaller
5249

5350
public static async Task EnsureTemplatingEngineInitializedAsync(ITestOutputHelper output)
5451
{
55-
Assert.True(await InstallerLock.WaitAsync(TimeSpan.FromMinutes(1)), "Unable to grab installer lock");
52+
await ProcessLock.DotNetNewLock.WaitAsync();
5653
try
5754
{
5855
if (!_haveReinstalledTemplatePackages)
@@ -67,7 +64,7 @@ public static async Task EnsureTemplatingEngineInitializedAsync(ITestOutputHelpe
6764
}
6865
finally
6966
{
70-
InstallerLock.Release();
67+
ProcessLock.DotNetNewLock.Release();
7168
}
7269
}
7370

0 commit comments

Comments
 (0)