Skip to content
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

Bootstrap improvements #10282

Merged
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
b132524
move tast to a separate project
YuliiaKovalova Jun 21, 2024
0b7dda0
logic updates
YuliiaKovalova Jun 24, 2024
0caf663
change output path
YuliiaKovalova Jun 24, 2024
0c02f33
adjust output paths
YuliiaKovalova Jun 24, 2024
9f29f6f
move to netstardard2.0
YuliiaKovalova Jun 24, 2024
23e753d
cleanup for non-windows
Jun 24, 2024
b51f097
update condition
YuliiaKovalova Jun 24, 2024
b12aac2
Merge branch 'dev/ykovalova/bootstrap_improvements' of https://github…
YuliiaKovalova Jun 24, 2024
0f00ef0
Base InstallDotNetCoreTask on stable packaged MSBuild
rainersigwald Jun 24, 2024
b2d83e5
change the copy logic
YuliiaKovalova Jun 24, 2024
c70792b
unify the version with PortableTask
YuliiaKovalova Jun 25, 2024
0907c8c
exclude deps.json from BootstrapNetCorePatch, return __NuGetRuntimeDe…
YuliiaKovalova Jun 26, 2024
6196063
fix path for Windows Full scenario and handle async script download s…
YuliiaKovalova Jun 27, 2024
675f275
adjust paths in e2e tests
YuliiaKovalova Jun 27, 2024
37656e0
add documentation
YuliiaKovalova Jul 1, 2024
a71e29c
extend the documentation
YuliiaKovalova Jul 1, 2024
53f0efd
Apply suggestions from Rainer's review
YuliiaKovalova Jul 11, 2024
e9ce4ef
fix review comments
YuliiaKovalova Jul 11, 2024
19ce1fc
Merge branch 'dotnet:main' into dev/ykovalova/bootstrap_improvements
YuliiaKovalova Jul 11, 2024
cb5dd94
use Task as a base class
YuliiaKovalova Jul 11, 2024
5b45a2b
onboard tooltask in InstallDotNetCoreTask
YuliiaKovalova Jul 11, 2024
5852b3d
fix review comments
YuliiaKovalova Jul 12, 2024
c0b6b35
cleanup
YuliiaKovalova Jul 12, 2024
9be76bc
InstallDotNetCoreTask via RoslynCodeTaskFactory
rainersigwald Jul 17, 2024
d0c2057
Acquire SDK earlier
rainersigwald Jul 17, 2024
9610b1d
update documentation
YuliiaKovalova Jul 17, 2024
b570043
move BootstrapSdkVersion to Versions.props
YuliiaKovalova Jul 18, 2024
c8532a0
Merge branch 'main' into dev/ykovalova/bootstrap_improvements
YuliiaKovalova Jul 30, 2024
73a0a6f
update documentation
YuliiaKovalova Jul 30, 2024
5cfef7b
undo extra changes
YuliiaKovalova Jul 30, 2024
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
26 changes: 26 additions & 0 deletions MSBuild.sln
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Build.BuildCheck.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Microsoft.Build.Templates", "template_feed\Microsoft.Build.Templates.csproj", "{A86EE74A-AEF0-42ED-A5A7-7A54BC0773D8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MSBuild.Bootstrap.Utils", "src\MSBuild.Bootstrap.Utils\MSBuild.Bootstrap.Utils.csproj", "{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -916,6 +918,30 @@ Global
{A86EE74A-AEF0-42ED-A5A7-7A54BC0773D8}.Release|x64.Build.0 = Release|Any CPU
{A86EE74A-AEF0-42ED-A5A7-7A54BC0773D8}.Release|x86.ActiveCfg = Release|Any CPU
{A86EE74A-AEF0-42ED-A5A7-7A54BC0773D8}.Release|x86.Build.0 = Release|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Debug|ARM64.Build.0 = Debug|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Debug|x64.ActiveCfg = Debug|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Debug|x64.Build.0 = Debug|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Debug|x86.ActiveCfg = Debug|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Debug|x86.Build.0 = Debug|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.MachineIndependent|Any CPU.ActiveCfg = MachineIndependent|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.MachineIndependent|Any CPU.Build.0 = MachineIndependent|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.MachineIndependent|ARM64.ActiveCfg = MachineIndependent|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.MachineIndependent|ARM64.Build.0 = MachineIndependent|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.MachineIndependent|x64.ActiveCfg = MachineIndependent|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.MachineIndependent|x64.Build.0 = MachineIndependent|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.MachineIndependent|x86.ActiveCfg = MachineIndependent|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.MachineIndependent|x86.Build.0 = MachineIndependent|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Release|Any CPU.Build.0 = Release|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Release|ARM64.ActiveCfg = Release|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Release|ARM64.Build.0 = Release|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Release|x64.ActiveCfg = Release|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Release|x64.Build.0 = Release|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Release|x86.ActiveCfg = Release|Any CPU
{E12F619A-80F1-4643-9AEC-D3D5C2FB8443}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
18 changes: 18 additions & 0 deletions documentation/wiki/Bootstrap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Quick Intro
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
The document describes the logic behind the bootstrap and testing capabilities for the fresh MSBuild bits.

## History
MSBuild supports two different environments: .NET and .NET Framework. To test changes for .NET, fresh bits were published (the actual target Publish run) to the MSBuild.Bootstrap folder. These bits, along with specific dependencies, were later copied to the bootstrap, making them ready for use with dotnet.exe. The executable is part of the .dotnet folder.
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved

## Current Implementation for .NET
During the bootstrap phase, install-scripts are used to download the bits compatible with the current version. The logic for interacting with the scripts has been encapsulated in a separate MSBuild task: InstallDotNetCoreTask.cs. Here’s what happens under the hood:
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved

The SDK is downloaded to the bootstrap folder.
Fresh MSBuild bits are then copied to this folder.
The constructed SDK is used for both local end-to-end tests and CI runs.

## Potential Cons
The reliance on downloading the SDK from a remote source requires an internet connection. For the initial build of the repository, this doesn't change as the SDK is always downloaded to the .dotnet folder first. However, for subsequent runs, the SDK will need to be downloaded again, which could be problematic in environments with limited or no internet connectivity.
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved

## Pros
This approach simplifies testing MSBuild as part of dotnet by providing a ready and reliable environment without needing to patch anything into a globally installed SDK, as was previously required.
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 9 additions & 6 deletions eng/BootStrapMsBuild.props
Original file line number Diff line number Diff line change
@@ -1,20 +1,23 @@
<Project>

<!--
Construct a location of MSBuild bootstrap folder - to be used for deployment and for tests
relying on bootstrapped MSBuild
-->
<!-- Construct a location of MSBuild bootstrap folder - to be used for deployment and for tests relying on bootstrapped MSBuild -->

<PropertyGroup Condition="!$(TargetFramework.StartsWith('net4'))">
<NetVersion>8.0.302</NetVersion>
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<PropertyGroup>
<BootstrapDestination>$(ArtifactsBinDir)bootstrap\</BootstrapDestination>
<BootstrapDestination Condition="'$(Platform)' == 'x64' or '$(Platform)' == 'arm64'">$(BootstrapDestination)$(Platform)\</BootstrapDestination>

<!-- This path is used for Windows Full test run and it points to net472 during execution-->
<BootstrapDestination>$(BootstrapDestination)$(TargetFramework.ToLowerInvariant())\MSBuild\</BootstrapDestination>
</PropertyGroup>

<PropertyGroup Condition="$(TargetFramework.StartsWith('net4'))">
<BootstrapBinaryDestination>$(BootstrapDestination)$(TargetMSBuildToolsVersion)\Bin</BootstrapBinaryDestination>
</PropertyGroup>

<PropertyGroup Condition="!$(TargetFramework.StartsWith('net4'))">
<BootstrapBinaryDestination>$(BootstrapDestination)</BootstrapBinaryDestination>
</PropertyGroup>
Expand Down
60 changes: 18 additions & 42 deletions eng/BootStrapMsBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -202,56 +202,32 @@
AlwaysCreate="true" />
</Target>

<!-- The task allow to download sdk bits for the specified version. It will be used later to bootstrap the runnable MSBuild. -->
<UsingTask TaskName="MSBuild.Bootstrap.Utils.Tasks.InstallDotNetCoreTask" AssemblyFile="$(ArtifactsBinDir)MSBuild.Bootstrap.Utils\$(Configuration)\netstandard2.0\MSBuild.Bootstrap.Utils.dll" TaskFactory="TaskHostFactory" />
<Target Name="BootstrapNetCore" DependsOnTargets="CleanBootstrapFolder">

<!-- Publish the project first. The more obvious way to do this would be to depend on the Publish target,
but that causes a target dependency cycle, even though it seems like AfterTargets="AfterBuild" should
probably not count as a link in the cycle. -->
<MSBuild Projects="$(MSBuildProjectFile)" Targets="Publish" BuildInParallel="$(BuildInParallel)" />
<PropertyGroup>
<InstallDir>$(ArtifactsBinDir)bootstrap\$(TargetFramework)\</InstallDir>
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
</PropertyGroup>

<ItemGroup>
<!-- Copy all items from the publish folder to the bootstrap folder. We might be able to just use the published
version as the bootstrapped version, but the extra separation here seems like it could be valuable. -->
<DeployedItems Include="$(PublishDir)\**\*.*" />

<NuGetSdkResolverManifest Include= "$(RepoRoot)src\MSBuild\SdkResolvers\Standalone\Microsoft.Build.NuGetSdkResolver.xml" />
<InstalledSdks Include="$(DOTNET_INSTALL_DIR)\sdk\$(DotNetCliVersion)\Sdks\**\*.*" />
<InstalledExtensions Include="$(DOTNET_INSTALL_DIR)\sdk\$(DotNetCliVersion)\Current\**\*.*" Exclude="$(DOTNET_INSTALL_DIR)\sdk\$(DotNetCliVersion)\Current\Microsoft.Common.props" />
</ItemGroup>
<Copy SourceFiles="@(DeployedItems)"
DestinationFolder="$(BootstrapDestination)%(RecursiveDir)" />

<Copy SourceFiles="@(NuGetSdkResolverManifest)"
DestinationFolder="$(BootstrapDestination)SdkResolvers\Microsoft.Build.NuGetSdkResolver" />

<Copy SourceFiles="$(RuntimeIdentifierGraphPath)"
DestinationFolder="$(BootstrapDestination)" />

<Copy SourceFiles="@(InstalledSdks)"
DestinationFiles="@(InstalledSdks -> '$(BootstrapDestination)Sdks\%(RecursiveDir)%(Filename)%(Extension)')" />

<!-- The .NET SDK has a dependency on DependencyModel, but relies on having it in the final
MSBuild.deps.json, which differs from ours because it's generated in the SDK repo.
<InstallDotNetCoreTask DotNetInstallScriptRootPath="$(DotNetRoot)" InstallDir="$(InstallDir)" Version="$(NetVersion)" DotNetInstallBaseUrl="https://raw.githubusercontent.com/dotnet/install-scripts/main/src/"/>
</Target>

Copy it from "next to MSBuild" in the pre-bootstrap SDK to our little weirdo bootstrap
layout next to the SDK tasks, so it can get loaded by the SDK tasks that need it. -->
<Copy SourceFiles="$(DOTNET_INSTALL_DIR)\sdk\$(DotNetCliVersion)\Microsoft.Extensions.DependencyModel.dll"
DestinationFolder="$(BootstrapDestination)Sdks\Microsoft.NET.Sdk\tools\$(LatestDotNetCoreForMSBuild)" />
<Target Name="BootstrapNetCorePatch" AfterTargets="BootstrapNetCore">

<Copy SourceFiles="@(InstalledExtensions)"
DestinationFolder="$(BootstrapDestination)Current\%(RecursiveDir)" />
<ItemGroup>
<!-- *.deps.json are excluded because they will cause the conflicts on an attempt to build solution with the bootstraped bits. -->
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
<FreshlyBuiltNetBinaries Include="$(OutDir)**\*.*" Exclude="$(OutDir)**\*.deps.json" />
</ItemGroup>

<!-- The copying of these dependencies is required by bootstrap\**\sdk\**\NuGet.RestoreEx.targets. Otherwise NuGet.Build.Tasks.dll can not be found. -->
<Copy SourceFiles="@(_NuGetRuntimeDependencies)"
DestinationFolder="$(BootstrapDestination)" />

<Copy SourceFiles="$(RepoRoot)src\MSBuild.Bootstrap\RedirectNuGetConsoleProcess.After.Microsoft.Common.targets"
DestinationFolder="$(BootstrapDestination)\Current\Microsoft.Common.targets\ImportAfter" />
DestinationFolder="$(InstallDir)sdk\$(NetVersion)\"
SkipUnchangedFiles="true" />

<Copy SourceFiles="$(RepoRoot)src\MSBuild.Bootstrap\RedirectNuGetConsoleProcess.After.Microsoft.Common.targets"
DestinationFolder="$(BootstrapDestination)\Current\SolutionFile\ImportAfter" />
<Copy SourceFiles="@(FreshlyBuiltNetBinaries)"
DestinationFiles="@(FreshlyBuiltNetBinaries->'$(InstallDir)sdk\$(NetVersion)\%(RecursiveDir)%(Filename)%(Extension)')" />

<!-- Disable workload resolver until we can figure out whether it can work in the bootstrap
https://github.com/dotnet/msbuild/issues/6566 -->
<Touch Files="$(BootstrapDestination)\DisableWorkloadResolver.sentinel" AlwaysCreate="true" />
</Target>

</Project>
7 changes: 5 additions & 2 deletions eng/cibuild_bootstrapped_msbuild.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,11 @@ try {
}
else
{
$buildToolPath = $dotnetExePath
$buildToolCommand = Join-Path $bootstrapRoot "net8.0\MSBuild\MSBuild.dll"
$buildToolPath = Join-Path $bootstrapRoot "net8.0\dotnet.exe"

# Must be consistent with the version in BootStrapMsBuild.props
$buildToolCommand = Join-Path $bootstrapRoot "net8.0\sdk\8.0.302\MSBuild.dll";
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved

$buildToolFramework = "net8.0"
}

Expand Down
6 changes: 4 additions & 2 deletions eng/cibuild_bootstrapped_msbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ bootstrapRoot="$Stage1Dir/bin/bootstrap"

if [ $host_type = "core" ]
then
_InitializeBuildTool="$_InitializeDotNetCli/dotnet"
_InitializeBuildToolCommand="$bootstrapRoot/net8.0/MSBuild/MSBuild.dll"
_InitializeBuildTool="$bootstrapRoot/net8.0/dotnet"

# Must be consistent with the version in BootStrapMsBuild.props
_InitializeBuildToolCommand="$bootstrapRoot/net8.0/sdk/8.0.302/MSBuild.dll"
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
_InitializeBuildToolFramework="net8.0"
else
echo "Unsupported hostType ($host_type)"
Expand Down
10 changes: 10 additions & 0 deletions src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Build.Utilities.Core" VersionOverride="15.5.180" ExcludeAssets="runtime" PrivateAssets="all" />
YuliiaKovalova marked this conversation as resolved.
Show resolved Hide resolved
</ItemGroup>

</Project>
Loading