Skip to content

Commit

Permalink
Inject updated list of feeds in csproj files (dotnet#669)
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienros authored Dec 14, 2023
1 parent e3e4139 commit 014339f
Showing 1 changed file with 28 additions and 35 deletions.
63 changes: 28 additions & 35 deletions src/Microsoft.Crank.Agent/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
using Serilog;
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;
using Vanara.PInvoke;
using OperatingSystem = Microsoft.Crank.Models.OperatingSystem;

namespace Microsoft.Crank.Agent
Expand Down Expand Up @@ -80,19 +79,22 @@ Based on the target framework
private static readonly string _aspNetCoreDependenciesUrl = "https://raw.githubusercontent.com/aspnet/AspNetCore/{0}";
private static readonly string _perfviewUrl = $"https://github.com/Microsoft/perfview/releases/download/{PerfViewVersion}/PerfView.exe";

private static readonly string _aspnet6FlatContainerUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/flat2/Microsoft.AspNetCore.App.Runtime.linux-x64/index.json";
private static readonly string _aspnet7FlatContainerUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/flat2/Microsoft.AspNetCore.App.Runtime.linux-x64/index.json";
private static readonly string _aspnet8FlatContainerUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/flat2/Microsoft.AspNetCore.App.Runtime.linux-x64/index.json";
private static readonly string _aspnet9FlatContainerUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/flat2/Microsoft.AspNetCore.App.Runtime.linux-x64/index.json";

private static readonly string _netcore6FlatContainerUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/flat2/Microsoft.NetCore.App.Runtime.linux-x64/index.json";
private static readonly string _netcore7FlatContainerUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/flat2/Microsoft.NetCore.App.Runtime.linux-x64/index.json";
private static readonly string _netcore8FlatContainerUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/flat2/Microsoft.NetCore.App.Runtime.linux-x64/index.json";
private static readonly string _netcore9FlatContainerUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/flat2/Microsoft.NetCore.App.Runtime.linux-x64/index.json";

private static readonly string additionalProjectSources = """
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/index.json;
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9-transport/nuget/v3/index.json;
https://dotnetfeed.blob.core.windows.net/aspnet-extensions/index.json;
https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore-tooling/index.json;
https://dotnetfeed.blob.core.windows.net/aspnet-entityframeworkcore/index.json;
https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/index.json;
""";

// Safe-keeping these urls
//private static readonly string _latestRuntimeApiUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/flat2/Microsoft.NetCore.App.Runtime.linux-x64/index.json";
//private static readonly string _latestDesktopApiUrl = "https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/flat2/Microsoft.NetCore.App.Runtime.win-x64/index.json";
//private static readonly string _releaseMetadata = "https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/releases-index.json";

private static readonly string _latestSdk90VersionUrl = "https://aka.ms/dotnet/9.0.1xx/daily/productCommit-win-x64.txt";
Expand All @@ -101,9 +103,6 @@ Based on the target framework
private static readonly string[] _runtimeFeedUrls = new string[] {
"https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9/nuget/v3/flat2",
"https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/flat2",
"https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/flat2",
"https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/flat2",
"https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/flat2",
"https://dotnetfeed.blob.core.windows.net/dotnet-core/flatcontainer",
"https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet-public/nuget/v3/flat2" };

Expand Down Expand Up @@ -3585,6 +3584,21 @@ await ProcessUtil.RetryOnExceptionAsync(3, async () =>
}
}

// Inject additional NuGet feeds directly in the csproj file.
// The global NuGet.config file created by crank may be ignored if the local project has
// a custom one with a <clear /> statement.

var propertyGroup = project.Root.Elements("PropertyGroup").FirstOrDefault(); ;

if (propertyGroup == null)
{
project.Root.Add(propertyGroup = new XElement("PropertyGroup"));
}

propertyGroup.Add(new XElement("RestoreAdditionalProjectSources", additionalProjectSources));

// Add FrameworkReference tags

if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
project.Root.Add(
Expand Down Expand Up @@ -3721,14 +3735,6 @@ private static async Task<string> ResolveAspNetCoreVersion(string aspNetCoreVers
aspNetCoreVersion = await GetFlatContainerVersion(_aspnet8FlatContainerUrl, versionPrefix, checkDotnetInstallUrl: true);
Log.Info($"ASP.NET: {aspNetCoreVersion} (Latest - From 8.0 feed)");
break;
case "7.0":
aspNetCoreVersion = await GetFlatContainerVersion(_aspnet7FlatContainerUrl, versionPrefix, checkDotnetInstallUrl: true);
Log.Info($"ASP.NET: {aspNetCoreVersion} (Latest - From 7.0 feed)");
break;
case "6.0":
aspNetCoreVersion = await GetFlatContainerVersion(_aspnet6FlatContainerUrl, versionPrefix, checkDotnetInstallUrl: true);
Log.Info($"ASP.NET: {aspNetCoreVersion} (Latest - From 6.0 feed)");
break;
default:
aspNetCoreVersion = currentAspNetCoreVersion;
Log.Info($"ASP.NET: {aspNetCoreVersion} (Latest - Fallback on Current)");
Expand Down Expand Up @@ -4060,16 +4066,6 @@ private static async Task<string> ResolveRuntimeVersion(string buildToolsPath, s
runtimeVersion = await GetFlatContainerVersion(_netcore8FlatContainerUrl, versionPrefix, checkDotnetInstallUrl: true);
Log.Info($"Runtime: {runtimeVersion} (Latest - From 8.0 feed)");
}
else if (versionPrefix == "7.0")
{
runtimeVersion = await GetFlatContainerVersion(_netcore7FlatContainerUrl, versionPrefix, checkDotnetInstallUrl: true);
Log.Info($"Runtime: {runtimeVersion} (Latest - From 7.0 feed)");
}
else if (versionPrefix == "6.0")
{
runtimeVersion = await GetFlatContainerVersion(_netcore6FlatContainerUrl, versionPrefix, checkDotnetInstallUrl: true);
Log.Info($"Runtime: {runtimeVersion} (Latest - From 6.0 feed)");
}
else
{
runtimeVersion = currentRuntimeVersion;
Expand Down Expand Up @@ -4620,8 +4616,9 @@ private static async Task<Process> StartProcess(string hostname, string benchmar
var arguments = process.StartInfo.Arguments;

// The executable should be in the same folder as the agent since it references the Console project
process.StartInfo.FileName = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Microsoft.Crank.JobObjectWrapper.exe");
process.StartInfo.Arguments = filename + " " + arguments;
// Use 'dotnet exec .dll' to use the current default dotnet version or the tests could fail if the .exe doesn't match what version is available locally
process.StartInfo.FileName = "dotnet";
process.StartInfo.Arguments = "exec" + " " + Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Microsoft.Crank.JobObjectWrapper.dll") + " " + filename + " " + arguments;

// .NET doesn't respect a cpu affinity if a ratio is not set too. https://github.com/dotnet/runtime/issues/94364
if (!String.IsNullOrWhiteSpace(job.CpuSet) && job.CpuLimitRatio == 0)
Expand Down Expand Up @@ -5955,7 +5952,7 @@ public static async Task EnsureDotnetInstallExistsAsync()
// This is not taken into account however if the source folder contains its own with a <clear /> statement as this one
// is defined in the root benchmarks agent folder.

var rootNugetConfig = Path.Combine(_rootTempDir, "NuGet.Config");
var rootNugetConfig = Path.Combine(_rootTempDir, "NuGet.config");

if (!File.Exists(rootNugetConfig))
{
Expand All @@ -5966,10 +5963,6 @@ public static async Task EnsureDotnetInstallExistsAsync()
<add key=""benchmarks-dotnet9-transport"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet9-transport/nuget/v3/index.json"" />
<add key=""benchmarks-dotnet8"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json"" />
<add key=""benchmarks-dotnet8-transport"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8-transport/nuget/v3/index.json"" />
<add key=""benchmarks-dotnet7"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7/nuget/v3/index.json"" />
<add key=""benchmarks-dotnet7-transport"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet7-transport/nuget/v3/index.json"" />
<add key=""benchmarks-dotnet6"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json"" />
<add key=""benchmarks-dotnet6-transport"" value=""https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6-transport/nuget/v3/index.json"" />
<add key=""benchmarks-aspnetcore"" value=""https://dotnetfeed.blob.core.windows.net/aspnet-aspnetcore/index.json"" />
<add key=""benchmarks-dotnet-core"" value=""https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json"" />
<add key=""benchmarks-extensions"" value=""https://dotnetfeed.blob.core.windows.net/aspnet-extensions/index.json"" />
Expand Down

0 comments on commit 014339f

Please sign in to comment.