Skip to content

Re-use the dotnet-new lock during template package installation #22007

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/ProjectTemplates/Shared/TemplatePackageInstaller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
using System.IO;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Internal;
using Microsoft.AspNetCore.Testing;
using Microsoft.Extensions.CommandLineUtils;
using Xunit;
using Xunit.Abstractions;
Expand All @@ -18,7 +16,6 @@ namespace Templates.Test.Helpers
{
internal static class TemplatePackageInstaller
{
private static readonly SemaphoreSlim InstallerLock = new SemaphoreSlim(1);
private static bool _haveReinstalledTemplatePackages;

private static readonly string[] _templatePackages = new[]
Expand Down Expand Up @@ -52,7 +49,7 @@ internal static class TemplatePackageInstaller

public static async Task EnsureTemplatingEngineInitializedAsync(ITestOutputHelper output)
{
Assert.True(await InstallerLock.WaitAsync(TimeSpan.FromMinutes(1)), "Unable to grab installer lock");
await ProcessLock.DotNetNewLock.WaitAsync();
try
{
if (!_haveReinstalledTemplatePackages)
Expand All @@ -67,7 +64,7 @@ public static async Task EnsureTemplatingEngineInitializedAsync(ITestOutputHelpe
}
finally
{
InstallerLock.Release();
ProcessLock.DotNetNewLock.Release();
}
}

Expand Down