From b9635390c8e8f0849b394c440b65e1ea3df2266b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=99emek=20Vysok=C3=BD?= Date: Tue, 23 Aug 2022 21:06:59 +0200 Subject: [PATCH] Add a VMR initialization (bootstrap) process (#14343) Adds the possibility to initialize a fresh VMR off of the current `dotnet/installer` commit. Similarly to the tarball generation, the process can be triggered by running: ``` ./build.sh /p:InitializeVMR=true /p:VmrDir=[Path were VMR will be created] ``` --- eng/Build.props | 38 +++-- eng/Version.Details.xml | 8 + eng/Versions.props | 5 + .../Arcade/src/SourceBuild.Tasks.csproj | 2 +- src/SourceBuild/Arcade/tools/BuildTasks.props | 2 +- .../tools/SourceBuildArcadeTarball.targets | 11 +- .../tarball/content/src/source-mappings.json | 140 ++++++++++++++++++ src/VirtualMonoRepo/InitializeVMR.proj | 121 +++++++++++++++ src/VirtualMonoRepo/Tasks/RemoteFactory.cs | 38 +++++ .../Tasks/VirtualMonoRepo.Tasks.csproj | 20 +++ .../Tasks/VirtualMonoRepo_Initialize.cs | 57 +++++++ 11 files changed, 424 insertions(+), 18 deletions(-) create mode 100644 src/SourceBuild/tarball/content/src/source-mappings.json create mode 100644 src/VirtualMonoRepo/InitializeVMR.proj create mode 100644 src/VirtualMonoRepo/Tasks/RemoteFactory.cs create mode 100644 src/VirtualMonoRepo/Tasks/VirtualMonoRepo.Tasks.csproj create mode 100644 src/VirtualMonoRepo/Tasks/VirtualMonoRepo_Initialize.cs diff --git a/eng/Build.props b/eng/Build.props index 4df683bab..2e1312f95 100644 --- a/eng/Build.props +++ b/eng/Build.props @@ -1,12 +1,30 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index e2fc8b58c..da74b22b8 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -213,6 +213,14 @@ https://github.com/dotnet/arcade 34dff939b4a91e4693f78a856e0e055c1a3f3fba + + https://github.com/dotnet/arcade-services + a27d5e56acf479b4a0944a0cf4511acb22d4a75b + + + https://github.com/dotnet/runtime + eecb02807867cad56cd05badddef65e432248b75 + https://github.com/dotnet/source-build-reference-packages c1bc837421e41a673cb30bf670c0cdd83ac09b75 diff --git a/eng/Versions.props b/eng/Versions.props index f831c36c8..6e569e714 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -28,6 +28,10 @@ 7.0.0-beta.22419.1 + + + 1.1.0-beta.22422.1 + 7.0.0-rc.1.22377.2 @@ -171,6 +175,7 @@ 2.2.0-beta.19072.10 2.0.0 17.4.0-preview-20220813-01 + 7.0.0-preview.7.22375.6 diff --git a/src/SourceBuild/Arcade/src/SourceBuild.Tasks.csproj b/src/SourceBuild/Arcade/src/SourceBuild.Tasks.csproj index 735289e70..2842d265d 100644 --- a/src/SourceBuild/Arcade/src/SourceBuild.Tasks.csproj +++ b/src/SourceBuild/Arcade/src/SourceBuild.Tasks.csproj @@ -1,6 +1,6 @@ - net5.0 + net7.0 false false disable diff --git a/src/SourceBuild/Arcade/tools/BuildTasks.props b/src/SourceBuild/Arcade/tools/BuildTasks.props index 4014b87ad..50f49046b 100644 --- a/src/SourceBuild/Arcade/tools/BuildTasks.props +++ b/src/SourceBuild/Arcade/tools/BuildTasks.props @@ -2,6 +2,6 @@ - $(RepoRoot)\artifacts\bin\SourceBuild.Tasks\$(Configuration)\net5.0\SourceBuild.Tasks.dll + $(RepoRoot)\artifacts\bin\SourceBuild.Tasks\$(Configuration)\net7.0\SourceBuild.Tasks.dll \ No newline at end of file diff --git a/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets b/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets index 1a652650a..5f61eb8ac 100644 --- a/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets +++ b/src/SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets @@ -14,7 +14,7 @@ $(RepoRoot)artifacts/ - $(ArtifactsDir)tarball/ + $(ArtifactsDir)tarball/ $([MSBuild]::EnsureTrailingSlash('$(TarballDir)')) $(TarballRootDir)src/ $(TarballRootDir)git-info/ @@ -234,8 +234,8 @@ SourceBuildMetadataDir="$(TarballGitInfoDir)" Dependencies="@(SourceBuildRepos)" /> - - + + - @@ -296,7 +296,7 @@ - @@ -428,4 +428,3 @@ - diff --git a/src/SourceBuild/tarball/content/src/source-mappings.json b/src/SourceBuild/tarball/content/src/source-mappings.json new file mode 100644 index 000000000..3144d9e23 --- /dev/null +++ b/src/SourceBuild/tarball/content/src/source-mappings.json @@ -0,0 +1,140 @@ +{ + "defaults": { + "defaultRef": "main", + "exclude": [ + "**/*.dll", + "**/*.Dll", + "**/*.exe", + "**/*.pdb", + "**/*.mdb", + "**/*.zip", + "**/*.nupkg" + ] + }, + "mappings": [ + { + "name": "arcade", + "defaultRemote": "https://github.com/dotnet/arcade", + "include": [ + "*.*", + ".*", + "eng/**/*", + "src/**/*", + "scripts/**/*" + ], + "exclude": [ + "**/tests/**/*", + "**/*.Tests/**/*" + ] + }, + { + "name": "aspnetcore", + "defaultRemote": "https://github.com/dotnet/aspnetcore" + }, + { + "name": "clicommandlineparser", + "defaultRemote": "https://github.com/dotnet/clicommandlineparser" + }, + { + "name": "command-line-api", + "defaultRemote": "https://github.com/dotnet/command-line-api" + }, + { + "name": "deployment-tools", + "defaultRemote": "https://github.com/dotnet/deployment-tools" + }, + { + "name": "diagnostics", + "defaultRemote": "https://github.com/dotnet/diagnostics" + }, + { + "name": "format", + "defaultRemote": "https://github.com/dotnet/format" + }, + { + "name": "fsharp", + "defaultRemote": "https://github.com/dotnet/fsharp" + }, + { + "name": "installer", + "defaultRemote": "https://github.com/dotnet/installer", + "defaultRef": "vmr" + }, + { + "name": "linker", + "defaultRemote": "https://github.com/dotnet/linker" + }, + { + "name": "msbuild", + "defaultRemote": "https://github.com/dotnet/msbuild" + }, + { + "name": "nuget-client", + "defaultRemote": "https://github.com/NuGet/NuGet.Client", + "defaultRef": "dev" + }, + { + "name": "razor-compiler", + "defaultRemote": "https://github.com/dotnet/razor-compiler" + }, + { + "name": "roslyn", + "defaultRemote": "https://github.com/dotnet/roslyn" + }, + { + "name": "roslyn-analyzers", + "defaultRemote": "https://github.com/dotnet/roslyn-analyzers" + }, + { + "name": "runtime", + "defaultRemote": "https://github.com/dotnet/runtime" + }, + { + "name": "sdk", + "defaultRemote": "https://github.com/dotnet/sdk" + }, + { + "name": "source-build", + "defaultRemote": "https://github.com/dotnet/source-build" + }, + { + "name": "source-build-externals", + "defaultRemote": "https://github.com/dotnet/source-build-externals", + "exclude": [ + "**/humanizer/samples/**/*.js" + ] + }, + { + "name": "source-build-reference-packages", + "defaultRemote": "https://github.com/dotnet/source-build-reference-packages" + }, + { + "name": "sourcelink", + "defaultRemote": "https://github.com/dotnet/sourcelink" + }, + { + "name": "symreader", + "defaultRemote": "https://github.com/dotnet/symreader" + }, + { + "name": "templating", + "defaultRemote": "https://github.com/dotnet/templating" + }, + { + "name": "test-templates", + "defaultRemote": "https://github.com/dotnet/test-templates" + }, + { + "name": "vstest", + "defaultRemote": "https://github.com/microsoft/vstest" + }, + { + "name": "xdt", + "defaultRemote": "https://github.com/dotnet/xdt" + }, + { + "name": "xliff-tasks", + "defaultRemote": "https://github.com/dotnet/xliff-tasks" + } + ] +} diff --git a/src/VirtualMonoRepo/InitializeVMR.proj b/src/VirtualMonoRepo/InitializeVMR.proj new file mode 100644 index 000000000..176498bff --- /dev/null +++ b/src/VirtualMonoRepo/InitializeVMR.proj @@ -0,0 +1,121 @@ + + + + $(RepoRoot)artifacts/ + $(ArtifactsDir)bin/VirtualMonoRepo.Tasks/$(Configuration)/net7.0/VirtualMonoRepo.Tasks.dll + + $([MSBuild]::EnsureTrailingSlash('$(VmrDir)')) + $(ArtifactsDir)tmp/ + main + + + $(VmrDir) + true + + + + + + + $(TarballGitInfoDir) + $(TarballSourceDir) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + $(SourceBuildRepoName)/ + $(VmrSourceDir)$(SourceDir) + $(IndividualRepoSourceDir)eng/ + $(IndividualRepoSourceEngDir)Version.Details.xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/VirtualMonoRepo/Tasks/RemoteFactory.cs b/src/VirtualMonoRepo/Tasks/RemoteFactory.cs new file mode 100644 index 000000000..cde8faadd --- /dev/null +++ b/src/VirtualMonoRepo/Tasks/RemoteFactory.cs @@ -0,0 +1,38 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Threading.Tasks; +using Microsoft.DotNet.DarcLib; +using Microsoft.DotNet.DarcLib.Helpers; + +namespace Microsoft.DotNet.VirtualMonoRepo.Tasks; + +internal class RemoteFactory : IRemoteFactory +{ + private readonly IProcessManager _processManager; + private readonly string _tmpPath; + + public RemoteFactory(IProcessManager processManager, string tmpPath) + { + _processManager = processManager; + _tmpPath = tmpPath; + } + + public Task GetBarOnlyRemoteAsync(Extensions.Logging.ILogger logger) + { + throw new NotImplementedException(); + } + + public Task GetRemoteAsync(string repoUrl, Extensions.Logging.ILogger logger) + { + var githubClient = new DarcLib.GitHubClient( + _processManager.GitExecutable, + accessToken: null, + logger, + _tmpPath, + cache: null); + + return System.Threading.Tasks.Task.FromResult(new Remote(githubClient, barClient: null, logger)); + } +} diff --git a/src/VirtualMonoRepo/Tasks/VirtualMonoRepo.Tasks.csproj b/src/VirtualMonoRepo/Tasks/VirtualMonoRepo.Tasks.csproj new file mode 100644 index 000000000..2d59069db --- /dev/null +++ b/src/VirtualMonoRepo/Tasks/VirtualMonoRepo.Tasks.csproj @@ -0,0 +1,20 @@ + + + net7.0 + preview + disable + false + false + false + false + true + + + + + + + + + + diff --git a/src/VirtualMonoRepo/Tasks/VirtualMonoRepo_Initialize.cs b/src/VirtualMonoRepo/Tasks/VirtualMonoRepo_Initialize.cs new file mode 100644 index 000000000..721bef092 --- /dev/null +++ b/src/VirtualMonoRepo/Tasks/VirtualMonoRepo_Initialize.cs @@ -0,0 +1,57 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System; +using System.Linq; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Build.Framework; +using Microsoft.DotNet.DarcLib; +using Microsoft.DotNet.DarcLib.Helpers; +using Microsoft.DotNet.DarcLib.VirtualMonoRepo; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace Microsoft.DotNet.VirtualMonoRepo.Tasks; + +public class VirtualMonoRepo_Initialize : Build.Utilities.Task, ICancelableTask +{ + private readonly Lazy _serviceProvider; + private readonly CancellationTokenSource _cancellationToken = new(); + + [Required] + public string Repository { get; set; } + + [Required] + public string VmrPath { get; set; } + + [Required] + public string TmpPath { get; set; } + + public string Revision { get; set; } + + public VirtualMonoRepo_Initialize() + { + _serviceProvider = new(CreateServiceProvider); + } + + public override bool Execute() => ExecuteAsync().GetAwaiter().GetResult(); + + private async Task ExecuteAsync() + { + var factory = _serviceProvider.Value.GetRequiredService(); + var vmrManager = await factory.CreateVmrManager(_serviceProvider.Value, VmrPath, TmpPath); + await vmrManager.InitializeVmr(Repository, Revision, false, _cancellationToken.Token); + return true; + } + + public void Cancel() => _cancellationToken.Cancel(); + + private IServiceProvider CreateServiceProvider() => new ServiceCollection() + .AddLogging(b => b.AddConsole().AddFilter(l => l >= LogLevel.Information)) + .AddTransient(sp => ActivatorUtilities.CreateInstance(sp, "git")) + .AddSingleton() + .AddSingleton() + .AddSingleton(sp => ActivatorUtilities.CreateInstance(sp, TmpPath)) + .BuildServiceProvider(); +}