[xharness] Serialize access to nuget. Fixes xamarin/maccore#1779. (#6402)

Nuget might freak out if multiple nuget processes run at the same time, so
make sure that doesn't happen.

Fixes https://github.com/xamarin/maccore/issues/1779.
This commit is contained in:
Rolf Bjarne Kvinge 2019-06-24 08:37:36 +02:00 коммит произвёл GitHub
Родитель 2e0a3f34ec
Коммит 84db931287
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
1 изменённых файлов: 32 добавлений и 29 удалений

Просмотреть файл

@ -72,6 +72,7 @@ namespace xharness
Dictionary<string, MakeTask> DependencyTasks = new Dictionary<string, MakeTask> ();
internal static Resource DesktopResource = new Resource ("Desktop", Environment.ProcessorCount);
internal static Resource NugetResource = new Resource ("Nuget", 1); // nuget is not parallel-safe :(
static Dictionary<string, Resource> device_resources = new Dictionary<string, Resource> ();
internal static Resources GetDeviceResources (IEnumerable<Device> devices)
@ -2222,9 +2223,9 @@ namespace xharness
}
}
var resources = device_resources.Values.Concat (new Resource [] { DesktopResource });
var resources = device_resources.Values.Concat (new Resource [] { DesktopResource, NugetResource });
if (resources.Any ()) {
writer.WriteLine ($"<h3>Devices:</h3>");
writer.WriteLine ($"<h3>Devices/Resources:</h3>");
foreach (var dr in resources.OrderBy ((v) => v.Description, StringComparer.OrdinalIgnoreCase)) {
writer.WriteLine ($"{dr.Description} - {dr.Users}/{dr.MaxConcurrentUsers} users - {dr.QueuedUsers} in queue<br />");
}
@ -2744,6 +2745,7 @@ namespace xharness
async Task<TestExecutingResult> RestoreNugetsAsync (string projectPath, Log log, bool useXIBuild=false)
{
using (var resource = await Jenkins.NugetResource.AcquireExclusiveAsync ()) {
// we do not want to use xibuild on solutions, we will have some failures with Mac Full
var isSolution = projectPath.EndsWith (".sln", StringComparison.Ordinal);
if (!File.Exists (projectPath))
@ -2776,6 +2778,7 @@ namespace xharness
LogEvent (log, "Restoring nugets completed for {0} ({1}) on path {2}", TestName, Mode, projectPath);
return TestExecutingResult.Succeeded;
}
}
List<string> GetNestedReferenceProjects (string csproj)
{