Fix VMR initialization (#15169)
Co-authored-by: Andrii Patsula <andriy.patsula@gmail.com>
This commit is contained in:
parent
fe452cf9cc
commit
118280814f
6 changed files with 70 additions and 21 deletions
|
@ -3,7 +3,6 @@
|
|||
<When Condition=" '$(InitializeVMR)' == 'true' ">
|
||||
<!-- VMR bootstrap -->
|
||||
<ItemGroup>
|
||||
<ProjectToBuild Include="$(RepoRoot)src/SourceBuild/Arcade/src/SourceBuild.Tasks.csproj" BuildInParallel="false" />
|
||||
<ProjectToBuild Include="$(RepoRoot)src/VirtualMonoRepo/Tasks/VirtualMonoRepo.Tasks.csproj" BuildInParallel="false" />
|
||||
<ProjectToBuild Include="$(RepoRoot)src/VirtualMonoRepo/InitializeVMR.proj" BuildInParallel="false" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -204,6 +204,12 @@
|
|||
<MicrosoftNETWorkloadEmscriptennet7Manifest80100Version>8.0.0-alpha.1.22620.1</MicrosoftNETWorkloadEmscriptennet7Manifest80100Version>
|
||||
<EmscriptenWorkloadManifestVersion>$(MicrosoftNETWorkloadEmscriptennet7Manifest80100Version)</EmscriptenWorkloadManifestVersion>
|
||||
</PropertyGroup>
|
||||
<!-- dependencies for VMR initialization -->
|
||||
<PropertyGroup>
|
||||
<!-- These two MicrosoftBuild versions are required to build VMR initialization tasks -->
|
||||
<MicrosoftBuildFrameworkVersion>15.7.179</MicrosoftBuildFrameworkVersion>
|
||||
<MicrosoftBuildUtilitiesCoreVersion>15.7.179</MicrosoftBuildUtilitiesCoreVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<!-- pinned dependency. This package is not being produced outside of the 2.0 branch of corefx and should not change. -->
|
||||
<CLI_NETStandardLibraryNETFrameworkVersion>2.0.1-servicing-26011-01</CLI_NETStandardLibraryNETFrameworkVersion>
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
<InitializeVMR>true</InitializeVMR>
|
||||
</PropertyGroup>
|
||||
|
||||
<Import Project="../SourceBuild/Arcade/tools/SourceBuildArcadeTarball.targets" />
|
||||
|
||||
<!-- Pull back in some properties from the tarball defaults -->
|
||||
<PropertyGroup>
|
||||
<VmrGitInfoDir>$(TarballGitInfoDir)</VmrGitInfoDir>
|
||||
|
@ -30,9 +28,7 @@
|
|||
Instead of cloning the repositories, we pull the sources via the `darc vmr initialize` command.
|
||||
Most of the targets are reused from the tarball generation process (SourceBuildArcadeTarball.targets).
|
||||
-->
|
||||
<Target Name="InitializeVMR" DependsOnTargets="GenerateFullNuGetVersion;
|
||||
GenerateVersionFile;
|
||||
InitializeCleanVmr;
|
||||
<Target Name="InitializeVMR" DependsOnTargets="InitializeCleanVmr;
|
||||
InitializeRepoAndDependentsRecursive">
|
||||
<Message Text="VMR was successfully initialized in '$(VmrDir)'" Importance="High" />
|
||||
</Target>
|
||||
|
@ -50,26 +46,24 @@
|
|||
<Exec WorkingDirectory="$(VmrDir)" Command="git commit -m 'Initial commit of the VMR%0D%0A%0D%0A[[ commit created by automation ]]'" />
|
||||
</Target>
|
||||
|
||||
<Target Name="InitializeRepoAndDependentsRecursive"
|
||||
DependsOnTargets="GetSourceBuildIntermediateNupkgNameConvention">
|
||||
<Target Name="InitializeRepoAndDependentsRecursive">
|
||||
<!-- Get installer's SHA if not passed in -->
|
||||
<Exec Command="git rev-parse HEAD" ConsoleToMSBuild="true" WorkingDirectory="$(RepoRoot)" Condition=" '$(TargetRevision)' == '' ">
|
||||
<Output TaskParameter="ConsoleOutput" ItemName="RootRepoCommitSha" />
|
||||
</Exec>
|
||||
|
||||
<PropertyGroup>
|
||||
<RootRepoName>$([System.IO.Path]::GetFileName("$(RepoRoot.TrimEnd('/').TrimEnd('\\'))"))</RootRepoName>
|
||||
<TargetRevision Condition=" '$(TargetRevision)' == '' ">@(RootRepoCommitSha)</TargetRevision>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Get installer's sha -->
|
||||
<Exec Command="git rev-parse HEAD" ConsoleToMSBuild="true" WorkingDirectory="$(RepoRoot)">
|
||||
<Output TaskParameter="ConsoleOutput" ItemName="RootRepoCommitSha" />
|
||||
</Exec>
|
||||
|
||||
<Message Text="--> Initializing individual repos recursively. Starting from $(RootRepoName) / $(TargetRevision)" Importance="High" />
|
||||
<Message Text="--> Initializing individual repos recursively. Starting from installer / $(TargetRevision)" Importance="High" />
|
||||
|
||||
<!-- We are hardcoding the package version for the root repo (installer), since there
|
||||
isn't a Version.Details.xml file to read it from.
|
||||
See https://github.com/dotnet/source-build/issues/2250 -->
|
||||
<VirtualMonoRepo_Initialize
|
||||
Repository="$(RootRepoName)"
|
||||
Repository="installer"
|
||||
Revision="$(TargetRevision)"
|
||||
PackageVersion="8.0.100"
|
||||
Recursive="true"
|
||||
|
@ -77,7 +71,6 @@
|
|||
TmpPath="$(TmpDir)" />
|
||||
|
||||
<Message Text=" -> Done initializing individual repositories recursively" Importance="High" />
|
||||
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
|
52
src/VirtualMonoRepo/Tasks/GitFileManagerFactory.cs
Normal file
52
src/VirtualMonoRepo/Tasks/GitFileManagerFactory.cs
Normal file
|
@ -0,0 +1,52 @@
|
|||
// 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 Microsoft.DotNet.DarcLib;
|
||||
using Microsoft.DotNet.DarcLib.Helpers;
|
||||
using Microsoft.DotNet.DarcLib.VirtualMonoRepo;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace Microsoft.DotNet.VirtualMonoRepo.Tasks;
|
||||
|
||||
public class GitFileManagerFactory : IGitFileManagerFactory
|
||||
{
|
||||
private readonly IVmrInfo _vmrInfo;
|
||||
private readonly VmrRemoteConfiguration _remoteConfiguration;
|
||||
private readonly IProcessManager _processManager;
|
||||
private readonly IVersionDetailsParser _versionDetailsParser;
|
||||
private readonly ILoggerFactory _loggerFactory;
|
||||
|
||||
public GitFileManagerFactory(
|
||||
IVmrInfo vmrInfo,
|
||||
VmrRemoteConfiguration remoteConfiguration,
|
||||
IProcessManager processManager,
|
||||
IVersionDetailsParser versionDetailsParser,
|
||||
ILoggerFactory loggerFactory)
|
||||
{
|
||||
_vmrInfo = vmrInfo;
|
||||
_remoteConfiguration = remoteConfiguration;
|
||||
_processManager = processManager;
|
||||
_versionDetailsParser = versionDetailsParser;
|
||||
_loggerFactory = loggerFactory;
|
||||
}
|
||||
|
||||
public IGitFileManager Create(string repoUri)
|
||||
=> new GitFileManager(CreateGitRepo(repoUri), _versionDetailsParser, _loggerFactory.CreateLogger<GitFileManager>());
|
||||
|
||||
private IGitRepo CreateGitRepo(string repoUri) => GitRepoTypeParser.ParseFromUri(repoUri) switch
|
||||
{
|
||||
GitRepoType.AzureDevOps => throw new Exception("VMR initialization should not require Azure DevOps repositories"),
|
||||
|
||||
GitRepoType.GitHub => new GitHubClient(
|
||||
_processManager.GitExecutable,
|
||||
_remoteConfiguration.GitHubToken,
|
||||
_loggerFactory.CreateLogger<GitHubClient>(),
|
||||
_vmrInfo.TmpPath,
|
||||
// Caching not in use for Darc local client.
|
||||
null),
|
||||
|
||||
GitRepoType.Local => new LocalGitClient(_processManager.GitExecutable, _loggerFactory.CreateLogger<LocalGitClient>()),
|
||||
_ => throw new ArgumentException("Unknown git repository type", nameof(repoUri)),
|
||||
};
|
||||
}
|
|
@ -7,8 +7,6 @@ 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;
|
||||
|
@ -61,6 +59,7 @@ public class VirtualMonoRepo_Initialize : Build.Utilities.Task, ICancelableTask
|
|||
|
||||
private IServiceProvider CreateServiceProvider() => new ServiceCollection()
|
||||
.AddLogging(b => b.AddConsole().AddFilter(l => l >= LogLevel.Information))
|
||||
.AddVmrManagers("git", VmrPath, TmpPath, null, null)
|
||||
.AddTransient<GitFileManagerFactory>()
|
||||
.AddVmrManagers(sp => sp.GetRequiredService<GitFileManagerFactory>(), "git", VmrPath, TmpPath, null, null)
|
||||
.BuildServiceProvider();
|
||||
}
|
||||
|
|
|
@ -105,8 +105,8 @@
|
|||
"defaultRef": "dev"
|
||||
},
|
||||
{
|
||||
"name": "razor-compiler",
|
||||
"defaultRemote": "https://github.com/dotnet/razor-compiler"
|
||||
"name": "razor",
|
||||
"defaultRemote": "https://github.com/dotnet/razor"
|
||||
},
|
||||
{
|
||||
"name": "roslyn",
|
||||
|
|
Loading…
Reference in a new issue