From b132524ba93da3bb5e850fff55eeddd4967dec8d Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Fri, 21 Jun 2024 18:54:31 +0200 Subject: [PATCH 01/27] move tast to a separate project --- MSBuild.sln | 26 ++++ eng/BootStrapMsBuild.targets | 56 ++------ src/MSBuild.Bootstrap.Utils/AssemblyInfo.cs | 4 + .../MSBuild.Bootstrap.Utils.csproj | 19 +++ .../Tasks/InstallDotNetCoreTask.cs | 126 ++++++++++++++++++ 5 files changed, 187 insertions(+), 44 deletions(-) create mode 100644 src/MSBuild.Bootstrap.Utils/AssemblyInfo.cs create mode 100644 src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj create mode 100644 src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs diff --git a/MSBuild.sln b/MSBuild.sln index 258d1a5c5d7..1669e3821ca 100644 --- a/MSBuild.sln +++ b/MSBuild.sln @@ -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 @@ -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 diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index 9209876eecf..044d1bdfabe 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -202,56 +202,24 @@ AlwaysCreate="true" /> + - - + + + - - - - - - - - - - - - - - - - - - + - + - - - + + + - + - - + diff --git a/src/MSBuild.Bootstrap.Utils/AssemblyInfo.cs b/src/MSBuild.Bootstrap.Utils/AssemblyInfo.cs new file mode 100644 index 00000000000..3b5d7bbb185 --- /dev/null +++ b/src/MSBuild.Bootstrap.Utils/AssemblyInfo.cs @@ -0,0 +1,4 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods; diff --git a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj new file mode 100644 index 00000000000..e8fa7d63ead --- /dev/null +++ b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj @@ -0,0 +1,19 @@ + + + + $(LatestDotNetCoreForMSBuild) + $(FullFrameworkTFM);$(TargetFrameworks) + + $(RuntimeOutputPlatformTarget) + false + True + + + + + + + + + + diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs new file mode 100644 index 00000000000..d6d4fc613a4 --- /dev/null +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -0,0 +1,126 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. + +using System.Diagnostics; +using Microsoft.Build.Framework; + +namespace MSBuild.Bootstrap.Utils.Tasks +{ + public sealed class InstallDotNetCoreTask : TaskExtension + { + private const string DotNetInstallBaseUrl = "https://dot.net/v1/"; + + public InstallDotNetCoreTask() + { + InstallDir = string.Empty; + DotNetInstallScript = string.Empty; + Channel = string.Empty; + } + + [Required] + public string InstallDir { get; set; } + + [Required] + public string DotNetInstallScript { get; set; } + + public string Channel { get; set; } + + public override bool Execute() + { + string scriptName = GetScriptName(); + string scriptPath = Path.Combine(DotNetInstallScript, scriptName); + + if (!File.Exists(scriptPath)) + { + DownloadScript(scriptName, scriptPath); + } + + string scriptArgs = GetScriptArgs(); + Log.LogMessage(MessageImportance.Low, $"Executing: {scriptPath} {scriptArgs}"); + + if (!NativeMethods.IsWindows) + { + MakeScriptExecutable(scriptPath); + } + + return RunScript(scriptPath, scriptArgs); + } + + private void DownloadScript(string scriptName, string scriptPath) + { + using (HttpClient client = new HttpClient()) + { + HttpResponseMessage response = client.GetAsync($"{DotNetInstallBaseUrl}{scriptName}").Result; + response.EnsureSuccessStatusCode(); + + string scriptContent = response.Content.ReadAsStringAsync().Result; + File.WriteAllText(scriptPath, scriptContent); + } + } + + private void MakeScriptExecutable(string scriptPath) + { + using (Process chmodProcess = new Process + { + StartInfo = new ProcessStartInfo + { + FileName = "chmod", + Arguments = $"+x {scriptPath}", + UseShellExecute = false + }, + }) + { + chmodProcess.Start(); + chmodProcess.WaitForExit(); + } + } + + private bool RunScript(string scriptPath, string scriptArgs) + { + ProcessStartInfo startInfo = new ProcessStartInfo + { + FileName = GetProcessName(), + Arguments = GetProcessArguments(scriptPath, scriptArgs), + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true + }; + + using (Process process = new Process { StartInfo = startInfo }) + { + process.Start(); + + string output = process.StandardOutput.ReadToEnd(); + Log.LogMessage(output); + + string errors = process.StandardError.ReadToEnd(); + process.WaitForExit(); + + if (process.ExitCode != 0) + { + if (!string.IsNullOrEmpty(errors)) + { + Log.LogError("Errors: " + errors); + } + + Log.LogError("dotnet-install failed"); + } + } + + return !Log.HasLoggedErrors; + } + + private string GetScriptName() => NativeMethodsShared.IsWindows ? "dotnet-install.ps1" : "dotnet-install.sh"; + + private string GetProcessName() => NativeMethodsShared.IsWindows ? "powershell.exe" : @"/bin/bash"; + + private string GetProcessArguments(string scriptPath, string scriptArgs) => NativeMethodsShared.IsWindows + ? $"-NoProfile -ExecutionPolicy Bypass -File \"{scriptPath}\" {scriptArgs}" + : $"{scriptPath} {scriptArgs}"; + + private string GetScriptArgs() => NativeMethodsShared.IsWindows + ? $"{(string.IsNullOrEmpty(Channel) ? "-Quality preview" : $"-Channel {Channel}")} -InstallDir {InstallDir}" + : $"{(string.IsNullOrEmpty(Channel) ? "--quality preview" : $"--channel {Channel}")} --install-dir {InstallDir}"; + } +} From 0b7dda080f81389f5665768a19aa255e902fba7c Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Mon, 24 Jun 2024 12:47:10 +0200 Subject: [PATCH 02/27] logic updates --- eng/BootStrapMsBuild.targets | 12 +- src/MSBuild.Bootstrap.Utils/AssemblyInfo.cs | 4 - .../MSBuild.Bootstrap.Utils.csproj | 10 +- .../Tasks/InstallDotNetCoreTask.cs | 113 +++++++++--------- 4 files changed, 66 insertions(+), 73 deletions(-) delete mode 100644 src/MSBuild.Bootstrap.Utils/AssemblyInfo.cs diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index 044d1bdfabe..b4b66ea6755 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -202,12 +202,14 @@ AlwaysCreate="true" /> - + - - - + + 8.0.302 + + + @@ -218,7 +220,7 @@ + DestinationFolder="$(BootstrapDestination)sdk\$(NetVersion)\%(RecursiveDir)" /> diff --git a/src/MSBuild.Bootstrap.Utils/AssemblyInfo.cs b/src/MSBuild.Bootstrap.Utils/AssemblyInfo.cs deleted file mode 100644 index 3b5d7bbb185..00000000000 --- a/src/MSBuild.Bootstrap.Utils/AssemblyInfo.cs +++ /dev/null @@ -1,4 +0,0 @@ -// Licensed to the .NET Foundation under one or more agreements. -// The .NET Foundation licenses this file to you under the MIT license. - -global using NativeMethodsShared = Microsoft.Build.Framework.NativeMethods; diff --git a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj index e8fa7d63ead..8c7d3033ee2 100644 --- a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj +++ b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj @@ -1,12 +1,10 @@ - - $(LatestDotNetCoreForMSBuild) - $(FullFrameworkTFM);$(TargetFrameworks) - + $(LatestDotNetCoreForMSBuild) $(RuntimeOutputPlatformTarget) false True + $(OutputPath)$(TargetFramework)\$(AssemblyName).dll @@ -15,5 +13,7 @@ - + + + diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs index d6d4fc613a4..fbd081a17d4 100644 --- a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -1,49 +1,49 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. +#if RUNTIME_TYPE_NETCORE + +using System; using System.Diagnostics; +using System.IO; +using System.Net.Http; +using System.Runtime.InteropServices; using Microsoft.Build.Framework; +using Microsoft.Build.Tasks; +using Microsoft.Build.Utilities; namespace MSBuild.Bootstrap.Utils.Tasks { - public sealed class InstallDotNetCoreTask : TaskExtension + public sealed class InstallDotNetCoreTask : Task { + private const string ScriptName = "dotnet-install"; private const string DotNetInstallBaseUrl = "https://dot.net/v1/"; public InstallDotNetCoreTask() { InstallDir = string.Empty; - DotNetInstallScript = string.Empty; - Channel = string.Empty; + DotNetInstallScriptRootPath = string.Empty; + Version = string.Empty; } [Required] public string InstallDir { get; set; } [Required] - public string DotNetInstallScript { get; set; } + public string DotNetInstallScriptRootPath { get; set; } - public string Channel { get; set; } + [Required] + public string Version { get; set; } public override bool Execute() { - string scriptName = GetScriptName(); - string scriptPath = Path.Combine(DotNetInstallScript, scriptName); - - if (!File.Exists(scriptPath)) + ScriptExecutionSettings executionSettings = SetupScriptsExecutionSettings(); + if (!File.Exists(executionSettings.ScriptsFullPath)) { - DownloadScript(scriptName, scriptPath); + DownloadScript(executionSettings.ScriptName, executionSettings.ScriptsFullPath); } - string scriptArgs = GetScriptArgs(); - Log.LogMessage(MessageImportance.Low, $"Executing: {scriptPath} {scriptArgs}"); - - if (!NativeMethods.IsWindows) - { - MakeScriptExecutable(scriptPath); - } - - return RunScript(scriptPath, scriptArgs); + return RunScript(executionSettings); } private void DownloadScript(string scriptName, string scriptPath) @@ -58,39 +58,11 @@ private void DownloadScript(string scriptName, string scriptPath) } } - private void MakeScriptExecutable(string scriptPath) - { - using (Process chmodProcess = new Process - { - StartInfo = new ProcessStartInfo - { - FileName = "chmod", - Arguments = $"+x {scriptPath}", - UseShellExecute = false - }, - }) - { - chmodProcess.Start(); - chmodProcess.WaitForExit(); - } - } - - private bool RunScript(string scriptPath, string scriptArgs) + private bool RunScript(ScriptExecutionSettings executionSettings) { - ProcessStartInfo startInfo = new ProcessStartInfo - { - FileName = GetProcessName(), - Arguments = GetProcessArguments(scriptPath, scriptArgs), - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true - }; - - using (Process process = new Process { StartInfo = startInfo }) + using (Process process = new Process { StartInfo = executionSettings.StartInfo }) { process.Start(); - string output = process.StandardOutput.ReadToEnd(); Log.LogMessage(output); @@ -103,24 +75,47 @@ private bool RunScript(string scriptPath, string scriptArgs) { Log.LogError("Errors: " + errors); } - - Log.LogError("dotnet-install failed"); } } return !Log.HasLoggedErrors; } - private string GetScriptName() => NativeMethodsShared.IsWindows ? "dotnet-install.ps1" : "dotnet-install.sh"; + private bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); - private string GetProcessName() => NativeMethodsShared.IsWindows ? "powershell.exe" : @"/bin/bash"; + private struct ScriptExecutionSettings(string executableName, ProcessStartInfo startInfo, string scriptName, string scriptsFullPath) + { + public string ExecutableName { get; } = executableName; - private string GetProcessArguments(string scriptPath, string scriptArgs) => NativeMethodsShared.IsWindows - ? $"-NoProfile -ExecutionPolicy Bypass -File \"{scriptPath}\" {scriptArgs}" - : $"{scriptPath} {scriptArgs}"; + public ProcessStartInfo StartInfo { get; } = startInfo; - private string GetScriptArgs() => NativeMethodsShared.IsWindows - ? $"{(string.IsNullOrEmpty(Channel) ? "-Quality preview" : $"-Channel {Channel}")} -InstallDir {InstallDir}" - : $"{(string.IsNullOrEmpty(Channel) ? "--quality preview" : $"--channel {Channel}")} --install-dir {InstallDir}"; + public string ScriptName { get; } = scriptName; + + public string ScriptsFullPath { get; } = scriptsFullPath; + } + + private ScriptExecutionSettings SetupScriptsExecutionSettings() + { + string scriptExtension = IsWindows ? "ps1" : "sh"; + string executableName = IsWindows ? "powershell.exe" : "/bin/bash"; + string scriptPath = Path.Combine(DotNetInstallScriptRootPath, $"{ScriptName}.{scriptExtension}"); + string scriptArgs = IsWindows + ? $"-NoProfile -ExecutionPolicy Bypass -File {scriptPath} -Version {Version} -InstallDir {InstallDir}" + : $"--version {Version} --install-dir {InstallDir}"; + + var startInfo = new ProcessStartInfo + { + FileName = IsWindows ? executableName : "chmod", + Arguments = IsWindows ? scriptArgs : $"+x {scriptPath} {scriptArgs}", + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true, + }; + + return new ScriptExecutionSettings(executableName, startInfo, $"{ScriptName}.{scriptExtension}", scriptPath); + } } } + +#endif From 0caf66332b8af017807127e2bfbd82edc49b4a0b Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Mon, 24 Jun 2024 13:06:35 +0200 Subject: [PATCH 03/27] change output path --- eng/BootStrapMsBuild.targets | 5 +++-- eng/cibuild_bootstrapped_msbuild.ps1 | 4 ++-- src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs | 2 -- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index b4b66ea6755..b0f3635c624 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -207,9 +207,10 @@ 8.0.302 + $(ArtifactsBinDir)bootstrap\$(TargetFramework)\ - + @@ -220,7 +221,7 @@ + DestinationFolder="$(InstallDir)sdk\$(NetVersion)" /> diff --git a/eng/cibuild_bootstrapped_msbuild.ps1 b/eng/cibuild_bootstrapped_msbuild.ps1 index b6e3c089135..27d122276b7 100644 --- a/eng/cibuild_bootstrapped_msbuild.ps1 +++ b/eng/cibuild_bootstrapped_msbuild.ps1 @@ -84,8 +84,8 @@ try { } else { - $buildToolPath = $dotnetExePath - $buildToolCommand = Join-Path $bootstrapRoot "net8.0\MSBuild\MSBuild.dll" + $buildToolPath = Join-Path $bootstrapRoot "net8.0\dotnet.exe" + $buildToolCommand = ""; $buildToolFramework = "net8.0" } diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs index fbd081a17d4..8b609c5f572 100644 --- a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -3,13 +3,11 @@ #if RUNTIME_TYPE_NETCORE -using System; using System.Diagnostics; using System.IO; using System.Net.Http; using System.Runtime.InteropServices; using Microsoft.Build.Framework; -using Microsoft.Build.Tasks; using Microsoft.Build.Utilities; namespace MSBuild.Bootstrap.Utils.Tasks From 0c02f33baaa21aeb4014bf8c1b45813fb513e28c Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Mon, 24 Jun 2024 14:16:00 +0200 Subject: [PATCH 04/27] adjust output paths --- eng/BootStrapMsBuild.targets | 5 ++--- src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj | 3 --- src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj | 3 ++- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index b0f3635c624..ad4be0ab52b 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -202,16 +202,15 @@ AlwaysCreate="true" /> - + 8.0.302 $(ArtifactsBinDir)bootstrap\$(TargetFramework)\ - + - diff --git a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj index 8c7d3033ee2..1c867265a36 100644 --- a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj +++ b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj @@ -4,7 +4,6 @@ $(RuntimeOutputPlatformTarget) false True - $(OutputPath)$(TargetFramework)\$(AssemblyName).dll @@ -14,6 +13,4 @@ - - diff --git a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj index 8a2a558e452..c0e2bb5c0f4 100644 --- a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj +++ b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj @@ -18,6 +18,7 @@ + @@ -47,7 +48,7 @@ - + From 9f29f6f53ce6091176bbcef2cf1698369da692c0 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Mon, 24 Jun 2024 15:56:17 +0200 Subject: [PATCH 05/27] move to netstardard2.0 --- eng/BootStrapMsBuild.targets | 2 +- src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj | 4 +--- src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs | 4 ---- src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj | 2 +- 4 files changed, 3 insertions(+), 9 deletions(-) diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index ad4be0ab52b..e0d12247078 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -202,7 +202,7 @@ AlwaysCreate="true" /> - + diff --git a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj index 1c867265a36..c727cde9549 100644 --- a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj +++ b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj @@ -1,6 +1,6 @@ - $(LatestDotNetCoreForMSBuild) + netstandard2.0 $(RuntimeOutputPlatformTarget) false True @@ -8,8 +8,6 @@ - - diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs index 8b609c5f572..42724fd6a68 100644 --- a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -7,7 +7,6 @@ using System.IO; using System.Net.Http; using System.Runtime.InteropServices; -using Microsoft.Build.Framework; using Microsoft.Build.Utilities; namespace MSBuild.Bootstrap.Utils.Tasks @@ -24,13 +23,10 @@ public InstallDotNetCoreTask() Version = string.Empty; } - [Required] public string InstallDir { get; set; } - [Required] public string DotNetInstallScriptRootPath { get; set; } - [Required] public string Version { get; set; } public override bool Execute() diff --git a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj index c0e2bb5c0f4..228dfedc820 100644 --- a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj +++ b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj @@ -18,7 +18,7 @@ - + From 23e753d55f6c3116d548cff5572f4f275ce30eaf Mon Sep 17 00:00:00 2001 From: Yuliia Kovalova Date: Mon, 24 Jun 2024 16:06:27 +0200 Subject: [PATCH 06/27] cleanup for non-windows --- .../Tasks/InstallDotNetCoreTask.cs | 31 +++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs index 42724fd6a68..5e11d8833b7 100644 --- a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -37,6 +37,8 @@ public override bool Execute() DownloadScript(executionSettings.ScriptName, executionSettings.ScriptsFullPath); } + MakeScriptExecutable(executionSettings.ScriptsFullPath); + return RunScript(executionSettings); } @@ -52,6 +54,31 @@ private void DownloadScript(string scriptName, string scriptPath) } } + private void MakeScriptExecutable(string scriptPath) + { + if (IsWindows) + { + return; + } + + using (var process = new Process + { + StartInfo = new ProcessStartInfo + { + FileName = "/bin/chmod", + Arguments = $"+x {scriptPath}", + RedirectStandardOutput = true, + RedirectStandardError = true, + UseShellExecute = false, + CreateNoWindow = true, + }, + }) + { + process.Start(); + process.WaitForExit(); + } + } + private bool RunScript(ScriptExecutionSettings executionSettings) { using (Process process = new Process { StartInfo = executionSettings.StartInfo }) @@ -99,8 +126,8 @@ private ScriptExecutionSettings SetupScriptsExecutionSettings() var startInfo = new ProcessStartInfo { - FileName = IsWindows ? executableName : "chmod", - Arguments = IsWindows ? scriptArgs : $"+x {scriptPath} {scriptArgs}", + FileName = executableName, + Arguments = scriptArgs, RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, From b51f097182e8f9051cae99a3c23280fcc727d7ac Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Mon, 24 Jun 2024 17:04:27 +0200 Subject: [PATCH 07/27] update condition --- src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj index 228dfedc820..c3a491af369 100644 --- a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj +++ b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj @@ -18,7 +18,7 @@ - + From 0f00ef05931844a3ce94c09b48903962dff7214b Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Mon, 24 Jun 2024 13:13:54 -0500 Subject: [PATCH 08/27] Base InstallDotNetCoreTask on stable packaged MSBuild NuGet asset resolution was picking the wrong TF when looking at ProjectReferences, so build this like an external consumer would. Co-authored-by: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com> --- eng/BootStrapMsBuild.targets | 4 ++-- src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index e0d12247078..ea093faae47 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -202,14 +202,14 @@ AlwaysCreate="true" /> - + 8.0.302 $(ArtifactsBinDir)bootstrap\$(TargetFramework)\ - + diff --git a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj index c727cde9549..1cdbd00e574 100644 --- a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj +++ b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj @@ -7,8 +7,7 @@ - - + From b2d83e5202ccee5e56a7ee7555c213ce99a41a70 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Mon, 24 Jun 2024 20:50:11 +0200 Subject: [PATCH 09/27] change the copy logic --- eng/BootStrapMsBuild.targets | 4 ++-- eng/cibuild_bootstrapped_msbuild.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index ea093faae47..d9d327ebde6 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -202,7 +202,7 @@ AlwaysCreate="true" /> - + @@ -220,7 +220,7 @@ + DestinationFiles="@(FreshlyBuiltNetBinaries->'$(InstallDir)sdk\$(NetVersion)\%(RecursiveDir)%(Filename)%(Extension)')" /> diff --git a/eng/cibuild_bootstrapped_msbuild.sh b/eng/cibuild_bootstrapped_msbuild.sh index 8edd377ec73..d1ebb55f28c 100755 --- a/eng/cibuild_bootstrapped_msbuild.sh +++ b/eng/cibuild_bootstrapped_msbuild.sh @@ -58,8 +58,8 @@ bootstrapRoot="$Stage1Dir/bin/bootstrap" if [ $host_type = "core" ] then - _InitializeBuildTool="$_InitializeDotNetCli/dotnet" - _InitializeBuildToolCommand="$bootstrapRoot/net8.0/MSBuild/MSBuild.dll" + _InitializeBuildTool="$bootstrapRoot/net8.0/dotnet" + _InitializeBuildToolCommand="" _InitializeBuildToolFramework="net8.0" else echo "Unsupported hostType ($host_type)" From c70792b61d77dc4a5a4cc80b0a96cf321deb924c Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Tue, 25 Jun 2024 14:07:04 +0200 Subject: [PATCH 10/27] unify the version with PortableTask --- src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj index 1cdbd00e574..179595c2350 100644 --- a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj +++ b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj @@ -1,13 +1,10 @@ netstandard2.0 - $(RuntimeOutputPlatformTarget) - false - True - + From 0907c8c1e028df0a06a9747fd70ee57507d7ed45 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Wed, 26 Jun 2024 22:20:28 +0200 Subject: [PATCH 11/27] exclude deps.json from BootstrapNetCorePatch, return __NuGetRuntimeDependencies --- eng/BootStrapMsBuild.props | 10 ++-- eng/BootStrapMsBuild.targets | 9 +++- eng/cibuild_bootstrapped_msbuild.ps1 | 8 +++- eng/cibuild_bootstrapped_msbuild.sh | 4 +- .../Tasks/InstallDotNetCoreTask.cs | 46 ++++++++++++------- .../MSBuild.Bootstrap.csproj | 2 +- src/MSBuild/XMake.cs | 2 +- .../BootstrapperUtil/BootstrapperBuilder.cs | 2 +- src/Tasks/Copy.cs | 2 +- src/Tasks/ManifestUtil/TrustInfo.cs | 2 +- 10 files changed, 57 insertions(+), 30 deletions(-) diff --git a/eng/BootStrapMsBuild.props b/eng/BootStrapMsBuild.props index 858cf76ac54..51cb0bb8ead 100644 --- a/eng/BootStrapMsBuild.props +++ b/eng/BootStrapMsBuild.props @@ -5,16 +5,20 @@ relying on bootstrapped MSBuild --> + + 8.0.302 + + $(ArtifactsBinDir)bootstrap\ $(BootstrapDestination)$(Platform)\ - $(BootstrapDestination)$(TargetFramework.ToLowerInvariant())\MSBuild\ + $(BootstrapDestination)$(TargetFramework.ToLowerInvariant())\sdk\$(NetVersion)\ - + $(BootstrapDestination)$(TargetMSBuildToolsVersion)\Bin - + $(BootstrapDestination) diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index d9d327ebde6..c9cf2f030be 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -206,7 +206,6 @@ - 8.0.302 $(ArtifactsBinDir)bootstrap\$(TargetFramework)\ @@ -216,9 +215,15 @@ - + + + + + diff --git a/eng/cibuild_bootstrapped_msbuild.ps1 b/eng/cibuild_bootstrapped_msbuild.ps1 index 27d122276b7..2d34c6854d5 100644 --- a/eng/cibuild_bootstrapped_msbuild.ps1 +++ b/eng/cibuild_bootstrapped_msbuild.ps1 @@ -78,14 +78,18 @@ try { if ($msbuildEngine -eq 'vs') { - $buildToolPath = Join-Path $bootstrapRoot "net472\MSBuild\Current\Bin\MSBuild.exe" + $buildToolPath = Join-Path $bootstrapRoot "net472\sdk\Current\Bin\MSBuild.exe" $buildToolCommand = ""; $buildToolFramework = "net472" } else { $buildToolPath = Join-Path $bootstrapRoot "net8.0\dotnet.exe" - $buildToolCommand = ""; + + # Must be consistent with the version in BootStrapMsBuild.props + $netVersion="8.0.302" + $buildToolCommand = Join-Path $bootstrapRoot "net8.0\sdk" $netVersion "MSBuild.dll"; + $buildToolFramework = "net8.0" } diff --git a/eng/cibuild_bootstrapped_msbuild.sh b/eng/cibuild_bootstrapped_msbuild.sh index d1ebb55f28c..e6d42eacbe8 100755 --- a/eng/cibuild_bootstrapped_msbuild.sh +++ b/eng/cibuild_bootstrapped_msbuild.sh @@ -55,11 +55,13 @@ then fi bootstrapRoot="$Stage1Dir/bin/bootstrap" +# Must be consistent with the version in BootStrapMsBuild.props +netVersion="8.0.302" if [ $host_type = "core" ] then _InitializeBuildTool="$bootstrapRoot/net8.0/dotnet" - _InitializeBuildToolCommand="" + _InitializeBuildToolCommand="$bootstrapRoot/net8.0/sdk/$netVersion/MSBuild.dll" _InitializeBuildToolFramework="net8.0" else echo "Unsupported hostType ($host_type)" diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs index 5e11d8833b7..a1c5ebf8df0 100644 --- a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -42,15 +42,23 @@ public override bool Execute() return RunScript(executionSettings); } - private void DownloadScript(string scriptName, string scriptPath) + private async void DownloadScript(string scriptName, string scriptPath) { using (HttpClient client = new HttpClient()) { - HttpResponseMessage response = client.GetAsync($"{DotNetInstallBaseUrl}{scriptName}").Result; - response.EnsureSuccessStatusCode(); - - string scriptContent = response.Content.ReadAsStringAsync().Result; - File.WriteAllText(scriptPath, scriptContent); + HttpResponseMessage response = await client.GetAsync($"{DotNetInstallBaseUrl}{scriptName}"); + if (response.IsSuccessStatusCode) + { + string scriptContent = await response.Content.ReadAsStringAsync(); + if (!string.IsNullOrEmpty(scriptContent)) + { + File.WriteAllText(scriptPath, scriptContent); + } + } + else + { + Log.LogError($"Install-scripts download from {DotNetInstallBaseUrl} error. Status code: {response.StatusCode}."); + } } } @@ -74,7 +82,7 @@ private void MakeScriptExecutable(string scriptPath) }, }) { - process.Start(); + _ = process.Start(); process.WaitForExit(); } } @@ -83,20 +91,24 @@ private bool RunScript(ScriptExecutionSettings executionSettings) { using (Process process = new Process { StartInfo = executionSettings.StartInfo }) { - process.Start(); - string output = process.StandardOutput.ReadToEnd(); - Log.LogMessage(output); + bool started = process.Start(); + if (started) + { + string output = process.StandardOutput.ReadToEnd() ?? string.Empty; + Log.LogMessage($"Install-scripts output logs: {output}"); - string errors = process.StandardError.ReadToEnd(); - process.WaitForExit(); + process.WaitForExit(); - if (process.ExitCode != 0) - { - if (!string.IsNullOrEmpty(errors)) + if (process.ExitCode != 0) { - Log.LogError("Errors: " + errors); + string errors = process.StandardError.ReadToEnd() ?? string.Empty; + Log.LogError("Install-scripts execution errors: " + errors); } } + else + { + Log.LogError("Process for install-scripts execution has not started."); + } } return !Log.HasLoggedErrors; @@ -122,7 +134,7 @@ private ScriptExecutionSettings SetupScriptsExecutionSettings() string scriptPath = Path.Combine(DotNetInstallScriptRootPath, $"{ScriptName}.{scriptExtension}"); string scriptArgs = IsWindows ? $"-NoProfile -ExecutionPolicy Bypass -File {scriptPath} -Version {Version} -InstallDir {InstallDir}" - : $"--version {Version} --install-dir {InstallDir}"; + : $"{scriptPath} --version {Version} --install-dir {InstallDir}"; var startInfo = new ProcessStartInfo { diff --git a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj index c3a491af369..b3246518064 100644 --- a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj +++ b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj @@ -18,7 +18,7 @@ - + diff --git a/src/MSBuild/XMake.cs b/src/MSBuild/XMake.cs index 088d2c00179..febd164695c 100644 --- a/src/MSBuild/XMake.cs +++ b/src/MSBuild/XMake.cs @@ -316,7 +316,7 @@ private static bool CanRunServerBasedOnCommandLineSwitches( commandLineSwitches.IsParameterizedSwitchSet(CommandLineSwitches.ParameterizedSwitch.NodeMode) || commandLineSwitches[CommandLineSwitches.ParameterlessSwitch.Version] || FileUtilities.IsBinaryLogFilename(projectFile) || - ProcessNodeReuseSwitch(commandLineSwitches[CommandLineSwitches.ParameterizedSwitch.NodeReuse]) == false || + !ProcessNodeReuseSwitch(commandLineSwitches[CommandLineSwitches.ParameterizedSwitch.NodeReuse]) || IsInteractiveBuild(commandLineSwitches)) { canRunServer = false; diff --git a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs index accb98d7438..c22ab73bc9f 100644 --- a/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs +++ b/src/Tasks/BootstrapperUtil/BootstrapperBuilder.cs @@ -2121,7 +2121,7 @@ private bool AddVerificationInformation(XmlNode packageFileNode, string fileSour // If the public key in the file doesn't match the public key on disk, issue a build warning // Skip this check if the public key attribute is "0", as this means we're expecting the public key // comparison to be skipped at install time because the file is signed by an MS trusted cert. - if (publicKeyAttribute.Value.Equals("0", StringComparison.OrdinalIgnoreCase) == false && + if (!publicKeyAttribute.Value.Equals("0", StringComparison.OrdinalIgnoreCase) && publicKey?.Equals(publicKeyAttribute.Value, StringComparison.OrdinalIgnoreCase) == false) { results?.AddMessage(BuildMessage.CreateMessage(BuildMessageSeverity.Warning, "GenerateBootstrapper.DifferingPublicKeys", PUBLICKEY_ATTRIBUTE, builder.Name, fileSource)); diff --git a/src/Tasks/Copy.cs b/src/Tasks/Copy.cs index c51b3db6e91..cbf1f263e91 100644 --- a/src/Tasks/Copy.cs +++ b/src/Tasks/Copy.cs @@ -288,7 +288,7 @@ private void LogAlwaysRetryDiagnosticFromResources(string messageResourceName, p } if (ChangeWaves.AreFeaturesEnabled(ChangeWaves.Wave17_8) && - Traits.Instance.EscapeHatches.CopyWithoutDelete != true && + !Traits.Instance.EscapeHatches.CopyWithoutDelete && destinationFileState.FileExists && !destinationFileState.IsReadOnly) { diff --git a/src/Tasks/ManifestUtil/TrustInfo.cs b/src/Tasks/ManifestUtil/TrustInfo.cs index 8776175eddc..bc10cb1d02c 100644 --- a/src/Tasks/ManifestUtil/TrustInfo.cs +++ b/src/Tasks/ManifestUtil/TrustInfo.cs @@ -500,7 +500,7 @@ private void ReadTrustInfo(string xml) // Partial trust is not supported on .NET Core. // Fail if loaded manifest does not specify full-trust. // It can happen if manifest is manually modifed. - if (unrestrictedAttribute == null || (false == Boolean.Parse(unrestrictedAttribute.Value))) + if (unrestrictedAttribute == null || (!Boolean.Parse(unrestrictedAttribute.Value))) { throw new ArgumentException("Partial trust is not supported."); } From 6196063dffa1123e5f39a3879c59c01459a44dc0 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Thu, 27 Jun 2024 12:20:21 +0200 Subject: [PATCH 12/27] fix path for Windows Full scenario and handle async script download scenario --- eng/BootStrapMsBuild.props | 7 +-- eng/BootStrapMsBuild.targets | 4 +- eng/cibuild_bootstrapped_msbuild.ps1 | 5 +- eng/cibuild_bootstrapped_msbuild.sh | 6 +-- .../Tasks/InstallDotNetCoreTask.cs | 53 ++++++++++++------- ...soleProcess.After.Microsoft.Common.targets | 23 -------- 6 files changed, 44 insertions(+), 54 deletions(-) delete mode 100644 src/MSBuild.Bootstrap/RedirectNuGetConsoleProcess.After.Microsoft.Common.targets diff --git a/eng/BootStrapMsBuild.props b/eng/BootStrapMsBuild.props index 51cb0bb8ead..299b89f609a 100644 --- a/eng/BootStrapMsBuild.props +++ b/eng/BootStrapMsBuild.props @@ -1,9 +1,6 @@ - + 8.0.302 @@ -12,7 +9,7 @@ $(ArtifactsBinDir)bootstrap\ $(BootstrapDestination)$(Platform)\ - $(BootstrapDestination)$(TargetFramework.ToLowerInvariant())\sdk\$(NetVersion)\ + $(BootstrapDestination)$(TargetFramework.ToLowerInvariant())\MSBuild\ diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index c9cf2f030be..3debcb95ad1 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -221,11 +221,11 @@ + DestinationFiles="@(FreshlyBuiltNetBinaries->'$(InstallDir)sdk\$(NetVersion)\%(RecursiveDir)%(Filename)%(Extension)')" /> diff --git a/eng/cibuild_bootstrapped_msbuild.ps1 b/eng/cibuild_bootstrapped_msbuild.ps1 index 2d34c6854d5..35ea847118c 100644 --- a/eng/cibuild_bootstrapped_msbuild.ps1 +++ b/eng/cibuild_bootstrapped_msbuild.ps1 @@ -78,7 +78,7 @@ try { if ($msbuildEngine -eq 'vs') { - $buildToolPath = Join-Path $bootstrapRoot "net472\sdk\Current\Bin\MSBuild.exe" + $buildToolPath = Join-Path $bootstrapRoot "net472\MSBuild\Current\Bin\MSBuild.exe" $buildToolCommand = ""; $buildToolFramework = "net472" } @@ -87,8 +87,7 @@ try { $buildToolPath = Join-Path $bootstrapRoot "net8.0\dotnet.exe" # Must be consistent with the version in BootStrapMsBuild.props - $netVersion="8.0.302" - $buildToolCommand = Join-Path $bootstrapRoot "net8.0\sdk" $netVersion "MSBuild.dll"; + $buildToolCommand = Join-Path $bootstrapRoot "net8.0\sdk\8.0.302\MSBuild.dll"; $buildToolFramework = "net8.0" } diff --git a/eng/cibuild_bootstrapped_msbuild.sh b/eng/cibuild_bootstrapped_msbuild.sh index e6d42eacbe8..d97ba471e7e 100755 --- a/eng/cibuild_bootstrapped_msbuild.sh +++ b/eng/cibuild_bootstrapped_msbuild.sh @@ -55,13 +55,13 @@ then fi bootstrapRoot="$Stage1Dir/bin/bootstrap" -# Must be consistent with the version in BootStrapMsBuild.props -netVersion="8.0.302" if [ $host_type = "core" ] then _InitializeBuildTool="$bootstrapRoot/net8.0/dotnet" - _InitializeBuildToolCommand="$bootstrapRoot/net8.0/sdk/$netVersion/MSBuild.dll" + + # Must be consistent with the version in BootStrapMsBuild.props + _InitializeBuildToolCommand="$bootstrapRoot/net8.0/sdk/8.0.302/MSBuild.dll" _InitializeBuildToolFramework="net8.0" else echo "Unsupported hostType ($host_type)" diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs index a1c5ebf8df0..008a86887c3 100644 --- a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -7,8 +7,11 @@ using System.IO; using System.Net.Http; using System.Runtime.InteropServices; +using Microsoft.Build.Framework; using Microsoft.Build.Utilities; +using AsyncTasks = System.Threading.Tasks; + namespace MSBuild.Bootstrap.Utils.Tasks { public sealed class InstallDotNetCoreTask : Task @@ -23,18 +26,23 @@ public InstallDotNetCoreTask() Version = string.Empty; } + [Required] public string InstallDir { get; set; } + [Required] public string DotNetInstallScriptRootPath { get; set; } + [Required] public string Version { get; set; } + private bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + public override bool Execute() { ScriptExecutionSettings executionSettings = SetupScriptsExecutionSettings(); if (!File.Exists(executionSettings.ScriptsFullPath)) { - DownloadScript(executionSettings.ScriptName, executionSettings.ScriptsFullPath); + AsyncTasks.Task.Run(() => DownloadScriptAsync(executionSettings.ScriptName, executionSettings.ScriptsFullPath)).GetAwaiter().GetResult(); } MakeScriptExecutable(executionSettings.ScriptsFullPath); @@ -42,14 +50,14 @@ public override bool Execute() return RunScript(executionSettings); } - private async void DownloadScript(string scriptName, string scriptPath) + private async AsyncTasks.Task DownloadScriptAsync(string scriptName, string scriptPath) { using (HttpClient client = new HttpClient()) { - HttpResponseMessage response = await client.GetAsync($"{DotNetInstallBaseUrl}{scriptName}"); + HttpResponseMessage response = await client.GetAsync($"{DotNetInstallBaseUrl}{scriptName}").ConfigureAwait(false); if (response.IsSuccessStatusCode) { - string scriptContent = await response.Content.ReadAsStringAsync(); + string scriptContent = await response.Content.ReadAsStringAsync().ConfigureAwait(false); if (!string.IsNullOrEmpty(scriptContent)) { File.WriteAllText(scriptPath, scriptContent); @@ -84,11 +92,22 @@ private void MakeScriptExecutable(string scriptPath) { _ = process.Start(); process.WaitForExit(); + + if (process.ExitCode != 0) + { + string errors = process.StandardError.ReadToEnd() ?? string.Empty; + Log.LogError($"Install-scripts can not be made executable due to the errors: {errors}."); + } } } private bool RunScript(ScriptExecutionSettings executionSettings) { + if (Log.HasLoggedErrors) + { + return false; + } + using (Process process = new Process { StartInfo = executionSettings.StartInfo }) { bool started = process.Start(); @@ -102,7 +121,7 @@ private bool RunScript(ScriptExecutionSettings executionSettings) if (process.ExitCode != 0) { string errors = process.StandardError.ReadToEnd() ?? string.Empty; - Log.LogError("Install-scripts execution errors: " + errors); + Log.LogError($"Install-scripts execution errors: {errors}"); } } else @@ -114,19 +133,6 @@ private bool RunScript(ScriptExecutionSettings executionSettings) return !Log.HasLoggedErrors; } - private bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); - - private struct ScriptExecutionSettings(string executableName, ProcessStartInfo startInfo, string scriptName, string scriptsFullPath) - { - public string ExecutableName { get; } = executableName; - - public ProcessStartInfo StartInfo { get; } = startInfo; - - public string ScriptName { get; } = scriptName; - - public string ScriptsFullPath { get; } = scriptsFullPath; - } - private ScriptExecutionSettings SetupScriptsExecutionSettings() { string scriptExtension = IsWindows ? "ps1" : "sh"; @@ -148,6 +154,17 @@ private ScriptExecutionSettings SetupScriptsExecutionSettings() return new ScriptExecutionSettings(executableName, startInfo, $"{ScriptName}.{scriptExtension}", scriptPath); } + + private struct ScriptExecutionSettings(string executableName, ProcessStartInfo startInfo, string scriptName, string scriptsFullPath) + { + public string ExecutableName { get; } = executableName; + + public ProcessStartInfo StartInfo { get; } = startInfo; + + public string ScriptName { get; } = scriptName; + + public string ScriptsFullPath { get; } = scriptsFullPath; + } } } diff --git a/src/MSBuild.Bootstrap/RedirectNuGetConsoleProcess.After.Microsoft.Common.targets b/src/MSBuild.Bootstrap/RedirectNuGetConsoleProcess.After.Microsoft.Common.targets deleted file mode 100644 index 3571d7e37f5..00000000000 --- a/src/MSBuild.Bootstrap/RedirectNuGetConsoleProcess.After.Microsoft.Common.targets +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - - - - From 675f275b114fc29e4a5ec815832d4ee36fc9ac6c Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Thu, 27 Jun 2024 14:26:31 +0200 Subject: [PATCH 13/27] adjust paths in e2e tests --- eng/BootStrapMsBuild.props | 2 ++ src/UnitTests.Shared/BootstrapLocationAttribute.cs | 7 ++++--- src/UnitTests.Shared/EnvironmentProvider.cs | 4 +++- .../Microsoft.Build.UnitTests.Shared.csproj | 11 ++++++++++- src/UnitTests.Shared/RunnerUtilities.cs | 6 +++--- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/eng/BootStrapMsBuild.props b/eng/BootStrapMsBuild.props index 299b89f609a..f38de56f1ad 100644 --- a/eng/BootStrapMsBuild.props +++ b/eng/BootStrapMsBuild.props @@ -9,6 +9,8 @@ $(ArtifactsBinDir)bootstrap\ $(BootstrapDestination)$(Platform)\ + + $(BootstrapDestination)$(TargetFramework.ToLowerInvariant())\MSBuild\ diff --git a/src/UnitTests.Shared/BootstrapLocationAttribute.cs b/src/UnitTests.Shared/BootstrapLocationAttribute.cs index 7f8627a69b3..f94b0628be9 100644 --- a/src/UnitTests.Shared/BootstrapLocationAttribute.cs +++ b/src/UnitTests.Shared/BootstrapLocationAttribute.cs @@ -6,8 +6,9 @@ namespace Microsoft.Build.UnitTests.Shared; [System.AttributeUsage(System.AttributeTargets.Assembly)] -internal sealed class BootstrapLocationAttribute(string bootstrapMsbuildBinaryLocation) - : System.Attribute +internal sealed class BootstrapLocationAttribute(string bootstrapMsBuildBinaryLocation, string netVersion) : System.Attribute { - public string BootstrapMsbuildBinaryLocation { get; } = bootstrapMsbuildBinaryLocation; + public string BootstrapMsBuildBinaryLocation { get; } = bootstrapMsBuildBinaryLocation; + + public string NetVersion { get; } = netVersion; } diff --git a/src/UnitTests.Shared/EnvironmentProvider.cs b/src/UnitTests.Shared/EnvironmentProvider.cs index 4ca3c276867..c0a7fcaddc4 100644 --- a/src/UnitTests.Shared/EnvironmentProvider.cs +++ b/src/UnitTests.Shared/EnvironmentProvider.cs @@ -74,7 +74,7 @@ private IEnumerable SearchPaths string? environmentOverride = _getEnvironmentVariable(Constants.DotnetMsbuildSdkResolverCliDir); if (!string.IsNullOrEmpty(environmentOverride)) { - return Path.Combine(environmentOverride, Constants.DotNet + Constants.ExeSuffix); + return GetDotnetExePathFromFolder(environmentOverride); } string? dotnetExe = _getCurrentProcessPath(); @@ -105,6 +105,8 @@ private IEnumerable SearchPaths return dotnetExe; } + public static string? GetDotnetExePathFromFolder(string? netRootFolder) => Path.Combine(netRootFolder ?? string.Empty, Constants.DotNet + Constants.ExeSuffix); + public static string? GetDotnetExePath(Func? getEnvironmentVariable = null) { if (getEnvironmentVariable == null) diff --git a/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj b/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj index fee3abf670f..4a254efc218 100644 --- a/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj +++ b/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj @@ -30,9 +30,18 @@ + + $(BootstrapDestination)Current\Bin + + + + $(ArtifactsBinDir)bootstrap\$(TargetFramework.ToLowerInvariant()) + + - <_Parameter1>$(BootstrapBinaryDestination) + <_Parameter1>$(TestBootstrapBinaryDestination) + <_Parameter2>$(NetVersion) diff --git a/src/UnitTests.Shared/RunnerUtilities.cs b/src/UnitTests.Shared/RunnerUtilities.cs index 8264bc07be9..344b6784e40 100644 --- a/src/UnitTests.Shared/RunnerUtilities.cs +++ b/src/UnitTests.Shared/RunnerUtilities.cs @@ -63,10 +63,10 @@ public static string ExecBootstrapedMSBuild( BootstrapLocationAttribute attribute = Assembly.GetExecutingAssembly().GetCustomAttribute() ?? throw new InvalidOperationException("This test assembly does not have the BootstrapLocationAttribute"); - string binaryFolder = attribute.BootstrapMsbuildBinaryLocation; + string binaryFolder = attribute.BootstrapMsBuildBinaryLocation; #if NET - string pathToExecutable = EnvironmentProvider.GetDotnetExePath()!; - msbuildParameters = Path.Combine(binaryFolder, "MSBuild.dll") + " " + msbuildParameters; + string pathToExecutable = EnvironmentProvider.GetDotnetExePathFromFolder(binaryFolder); + msbuildParameters = Path.Combine(binaryFolder, "sdk", attribute.NetVersion, "MSBuild.dll") + " " + msbuildParameters; #else string pathToExecutable = Path.Combine(binaryFolder, "MSBuild.exe"); #endif From 37656e0fe2da3bc854d5fc4ff312a72d4ba88b8c Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Mon, 1 Jul 2024 19:22:16 +0200 Subject: [PATCH 14/27] add documentation --- documentation/wiki/Bootstrap.md | 12 +++++ eng/BootStrapMsBuild.targets | 3 +- .../Tasks/InstallDotNetCoreTask.cs | 50 +++++++++++++++++-- 3 files changed, 60 insertions(+), 5 deletions(-) create mode 100644 documentation/wiki/Bootstrap.md diff --git a/documentation/wiki/Bootstrap.md b/documentation/wiki/Bootstrap.md new file mode 100644 index 00000000000..2f194488b5b --- /dev/null +++ b/documentation/wiki/Bootstrap.md @@ -0,0 +1,12 @@ +## Quick Intro +The document describes the logic behind the bootstrap and testing capabilities for the fresh MSBuild bits. + +## History +MSBuild is built for two different environments: .NET and .NET Framework. To check the changes for .NET, the fresh bits were published to the MSBuild.Bootstrap folder and copied to the bootstrap later together with a set of specific dependencies to make it work as a part of the .dotnet folder. + +## Current Implementation for .NET +During the bootstrap phase, install-scripts is used for downloading the bits that are compatible with the current version. The logic of interplay with the scripts is moved to a separate MSBuild task: InstallDotNetCoreTask.cs. What happens under the hood: + + 1. The SDK is downloaded in the bootstrap folder. + 2. Fresh MSBuild bits are copied to it later. + 3. The constructed SDK is used for testing for both: local e2e tests and CI runs. \ No newline at end of file diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index 3debcb95ad1..6f84e7eb3a5 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -202,6 +202,7 @@ AlwaysCreate="true" /> + @@ -209,7 +210,7 @@ $(ArtifactsBinDir)bootstrap\$(TargetFramework)\ - + diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs index 008a86887c3..c5a8f2f1472 100644 --- a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -14,11 +14,17 @@ namespace MSBuild.Bootstrap.Utils.Tasks { + /// + /// This task is designed to automate the installation of .NET Core SDK. + /// It downloads the appropriate installation script and executes it to install the specified version of .NET Core SDK. + /// public sealed class InstallDotNetCoreTask : Task { private const string ScriptName = "dotnet-install"; - private const string DotNetInstallBaseUrl = "https://dot.net/v1/"; + /// + /// Initializes a new instance of the class. + /// public InstallDotNetCoreTask() { InstallDir = string.Empty; @@ -26,17 +32,35 @@ public InstallDotNetCoreTask() Version = string.Empty; } + /// + /// Gets or sets the directory where the .NET Core SDK should be installed. This property is required. + /// [Required] public string InstallDir { get; set; } + /// + /// Gets or sets the root path where the .NET Core installation script is located. This property is required. + /// [Required] public string DotNetInstallScriptRootPath { get; set; } + /// + /// Gets or sets the version of the .NET Core SDK to be installed. This property is required. + /// [Required] public string Version { get; set; } + /// + /// Gets or sets the base URL for downloading the .NET Core installation script. The default value is "https://dot.net/v1/". + /// + public string DotNetInstallBaseUrl { get; set; } = "https://dot.net/v1/"; + private bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + /// + /// Executes the task, downloading and running the .NET Core installation script. + /// + /// True if the task succeeded; otherwise, false. public override bool Execute() { ScriptExecutionSettings executionSettings = SetupScriptsExecutionSettings(); @@ -50,6 +74,11 @@ public override bool Execute() return RunScript(executionSettings); } + /// + /// Downloads the .NET Core installation script asynchronously from the specified URL. + /// + /// The name of the script to download. + /// The path where the script will be saved. private async AsyncTasks.Task DownloadScriptAsync(string scriptName, string scriptPath) { using (HttpClient client = new HttpClient()) @@ -70,6 +99,10 @@ private async AsyncTasks.Task DownloadScriptAsync(string scriptName, string scri } } + /// + /// Makes the installation script executable on non-Windows platforms. + /// + /// The path of the script to make executable. private void MakeScriptExecutable(string scriptPath) { if (IsWindows) @@ -101,6 +134,11 @@ private void MakeScriptExecutable(string scriptPath) } } + /// + /// Runs the .NET Core installation script with the specified settings. + /// + /// The settings required for script execution. + /// True if the script executed successfully; otherwise, false. private bool RunScript(ScriptExecutionSettings executionSettings) { if (Log.HasLoggedErrors) @@ -133,6 +171,10 @@ private bool RunScript(ScriptExecutionSettings executionSettings) return !Log.HasLoggedErrors; } + /// + /// Sets up the settings required for executing the .NET Core installation script. + /// + /// The settings required for script execution. private ScriptExecutionSettings SetupScriptsExecutionSettings() { string scriptExtension = IsWindows ? "ps1" : "sh"; @@ -155,14 +197,14 @@ private ScriptExecutionSettings SetupScriptsExecutionSettings() return new ScriptExecutionSettings(executableName, startInfo, $"{ScriptName}.{scriptExtension}", scriptPath); } + /// + /// A private struct to hold settings for script execution. + /// private struct ScriptExecutionSettings(string executableName, ProcessStartInfo startInfo, string scriptName, string scriptsFullPath) { public string ExecutableName { get; } = executableName; - public ProcessStartInfo StartInfo { get; } = startInfo; - public string ScriptName { get; } = scriptName; - public string ScriptsFullPath { get; } = scriptsFullPath; } } From a71e29ce2b3dfcb2f58a946b751a48a84ceda4f5 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Mon, 1 Jul 2024 19:41:47 +0200 Subject: [PATCH 15/27] extend the documentation --- documentation/wiki/Bootstrap.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/documentation/wiki/Bootstrap.md b/documentation/wiki/Bootstrap.md index 2f194488b5b..cd814442ce7 100644 --- a/documentation/wiki/Bootstrap.md +++ b/documentation/wiki/Bootstrap.md @@ -2,11 +2,17 @@ The document describes the logic behind the bootstrap and testing capabilities for the fresh MSBuild bits. ## History -MSBuild is built for two different environments: .NET and .NET Framework. To check the changes for .NET, the fresh bits were published to the MSBuild.Bootstrap folder and copied to the bootstrap later together with a set of specific dependencies to make it work as a part of the .dotnet folder. +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. ## Current Implementation for .NET -During the bootstrap phase, install-scripts is used for downloading the bits that are compatible with the current version. The logic of interplay with the scripts is moved to a separate MSBuild task: InstallDotNetCoreTask.cs. What happens under the hood: +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: - 1. The SDK is downloaded in the bootstrap folder. - 2. Fresh MSBuild bits are copied to it later. - 3. The constructed SDK is used for testing for both: local e2e tests and CI runs. \ No newline at end of file +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. + +## 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. \ No newline at end of file From 53f0efd667c53975c37c559ac1ef804f7676c6b5 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com> Date: Thu, 11 Jul 2024 10:28:06 +0200 Subject: [PATCH 16/27] Apply suggestions from Rainer's review Co-authored-by: Rainer Sigwald --- documentation/wiki/Bootstrap.md | 8 ++++++-- src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/documentation/wiki/Bootstrap.md b/documentation/wiki/Bootstrap.md index cd814442ce7..059131f99a5 100644 --- a/documentation/wiki/Bootstrap.md +++ b/documentation/wiki/Bootstrap.md @@ -1,11 +1,15 @@ +# Bootstrap MSBuild + +Because the binaries and build logic in this repo aren't sufficient to build real-world projects, we need a test environment that mimics the real-world combinations of MSBuild, Roslyn compilers, and other things that combine in the .NET SDK and in Visual Studio to produce a functional build environment. We call this the "bootstrap". + ## Quick Intro 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. +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 combined with parts of the .NET SDK that was used to build MSBuild to the bootstrap, making them ready for use with dotnet.exe. To execute the bootstrap MSBuild, you'd combine the `dotnet.exe` muxer from the .dotnet folder with the path to the bootstrap's `MSBuild.dll`. ## 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: +During the bootstrap phase, install-scripts are used to download a full copy of the .NET SDK 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: The SDK is downloaded to the bootstrap folder. Fresh MSBuild bits are then copied to this folder. diff --git a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj index b3246518064..d83b9a6b34b 100644 --- a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj +++ b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj @@ -18,7 +18,7 @@ - + From e9ce4ef383240246c36adea462fdf9a16e852f2b Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Thu, 11 Jul 2024 19:02:54 +0200 Subject: [PATCH 17/27] fix review comments --- documentation/release-checklist.md | 1 + documentation/wiki/Bootstrap.md | 2 +- eng/BootStrapMsBuild.targets | 6 ++--- eng/cibuild_bootstrapped_msbuild.ps1 | 7 ++--- eng/cibuild_bootstrapped_msbuild.sh | 6 ++--- .../MSBuild.Bootstrap.Utils.csproj | 2 +- .../Tasks/InstallDotNetCoreTask.cs | 26 ++++++++++++------- .../MSBuild.Bootstrap.csproj | 3 +-- src/Tasks/Microsoft.Build.Tasks.csproj | 6 ----- .../Microsoft.Build.UnitTests.Shared.csproj | 2 +- 10 files changed, 28 insertions(+), 33 deletions(-) diff --git a/documentation/release-checklist.md b/documentation/release-checklist.md index 4f00f360e55..3ae646c436c 100644 --- a/documentation/release-checklist.md +++ b/documentation/release-checklist.md @@ -56,6 +56,7 @@ https://ceapex.visualstudio.com/CEINTL/_workitems/edit/957875 (DONE) - [ ] Get M2 or QB approval as necessary per the VS schedule - [ ] Merge to VS (babysit the automatically generated VS insertion PR https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequests for the MSBuild commit noted in above step): {{URL_OF_VS_INSERTION}} - [ ] Update the PackageValidationBaselineVersion to the latest released version ({{THIS_RELEASE_VERSION}}.0) - this might require temporary addition of the [build artifacts feed](https://github.com/dotnet/msbuild/blob/29397b577e3ec0fe0c7650c3ab0400909655dc88/NuGet.config#L9) as the new version is not yet added to the official feeds (this is post release). This can trigger a high severity CG error (https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/secure-supply-chain/how-to-securely-configure-package-source-files) - however it should be fine to keep this temporary feed untill the release. +- [ ] Update the requested SDK version for bootstrap folder if a fresh sdk was released in [NetVersion](https://github.com/dotnet/msbuild/blob/main/eng/BootStrapMsBuild.props). ## ASAP On/After GA: diff --git a/documentation/wiki/Bootstrap.md b/documentation/wiki/Bootstrap.md index 059131f99a5..e33007c0f73 100644 --- a/documentation/wiki/Bootstrap.md +++ b/documentation/wiki/Bootstrap.md @@ -16,7 +16,7 @@ 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. +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. For subsequent runs, the SDK in bootstrap will be downloaded again only **if the requested version was changed**. ## 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. \ No newline at end of file diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index 6f84e7eb3a5..a33110623e1 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -204,13 +204,13 @@ - + - $(ArtifactsBinDir)bootstrap\$(TargetFramework)\ + $(ArtifactsBinDir)bootstrap\core\ - + diff --git a/eng/cibuild_bootstrapped_msbuild.ps1 b/eng/cibuild_bootstrapped_msbuild.ps1 index 35ea847118c..22bbf5dd3f1 100644 --- a/eng/cibuild_bootstrapped_msbuild.ps1 +++ b/eng/cibuild_bootstrapped_msbuild.ps1 @@ -84,11 +84,8 @@ try { } else { - $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"; - + $buildToolPath = Join-Path $bootstrapRoot "core\dotnet.exe" + $buildToolCommand = "msbuild"; $buildToolFramework = "net8.0" } diff --git a/eng/cibuild_bootstrapped_msbuild.sh b/eng/cibuild_bootstrapped_msbuild.sh index d97ba471e7e..2539d025c26 100755 --- a/eng/cibuild_bootstrapped_msbuild.sh +++ b/eng/cibuild_bootstrapped_msbuild.sh @@ -58,10 +58,8 @@ bootstrapRoot="$Stage1Dir/bin/bootstrap" if [ $host_type = "core" ] then - _InitializeBuildTool="$bootstrapRoot/net8.0/dotnet" - - # Must be consistent with the version in BootStrapMsBuild.props - _InitializeBuildToolCommand="$bootstrapRoot/net8.0/sdk/8.0.302/MSBuild.dll" + _InitializeBuildTool="$bootstrapRoot/core/dotnet" + _InitializeBuildToolCommand="build" _InitializeBuildToolFramework="net8.0" else echo "Unsupported hostType ($host_type)" diff --git a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj index 179595c2350..7539d0dcedb 100644 --- a/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj +++ b/src/MSBuild.Bootstrap.Utils/MSBuild.Bootstrap.Utils.csproj @@ -7,4 +7,4 @@ - + \ No newline at end of file diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs index c5a8f2f1472..409d213f7e2 100644 --- a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -1,8 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -#if RUNTIME_TYPE_NETCORE - using System.Diagnostics; using System.IO; using System.Net.Http; @@ -18,7 +16,7 @@ namespace MSBuild.Bootstrap.Utils.Tasks /// This task is designed to automate the installation of .NET Core SDK. /// It downloads the appropriate installation script and executes it to install the specified version of .NET Core SDK. /// - public sealed class InstallDotNetCoreTask : Task + public sealed class InstallDotNetCoreTask : ToolTask { private const string ScriptName = "dotnet-install"; @@ -57,12 +55,20 @@ public InstallDotNetCoreTask() private bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + protected override string ToolName => IsWindows ? "powershell.exe" : "/bin/bash"; + /// /// Executes the task, downloading and running the .NET Core installation script. /// /// True if the task succeeded; otherwise, false. public override bool Execute() { + if (Directory.Exists(InstallDir) || Directory.Exists(Path.Combine(InstallDir, "sdk", Version))) + { + // no need to download sdk again, it exists locally + return true; + } + ScriptExecutionSettings executionSettings = SetupScriptsExecutionSettings(); if (!File.Exists(executionSettings.ScriptsFullPath)) { @@ -74,6 +80,8 @@ public override bool Execute() return RunScript(executionSettings); } + protected override string GenerateFullPathToTool() => ToolName; + /// /// Downloads the .NET Core installation script asynchronously from the specified URL. /// @@ -178,7 +186,6 @@ private bool RunScript(ScriptExecutionSettings executionSettings) private ScriptExecutionSettings SetupScriptsExecutionSettings() { string scriptExtension = IsWindows ? "ps1" : "sh"; - string executableName = IsWindows ? "powershell.exe" : "/bin/bash"; string scriptPath = Path.Combine(DotNetInstallScriptRootPath, $"{ScriptName}.{scriptExtension}"); string scriptArgs = IsWindows ? $"-NoProfile -ExecutionPolicy Bypass -File {scriptPath} -Version {Version} -InstallDir {InstallDir}" @@ -186,7 +193,7 @@ private ScriptExecutionSettings SetupScriptsExecutionSettings() var startInfo = new ProcessStartInfo { - FileName = executableName, + FileName = ToolName, Arguments = scriptArgs, RedirectStandardOutput = true, RedirectStandardError = true, @@ -194,20 +201,19 @@ private ScriptExecutionSettings SetupScriptsExecutionSettings() CreateNoWindow = true, }; - return new ScriptExecutionSettings(executableName, startInfo, $"{ScriptName}.{scriptExtension}", scriptPath); + return new ScriptExecutionSettings(startInfo, $"{ScriptName}.{scriptExtension}", scriptPath); } /// /// A private struct to hold settings for script execution. /// - private struct ScriptExecutionSettings(string executableName, ProcessStartInfo startInfo, string scriptName, string scriptsFullPath) + private struct ScriptExecutionSettings(ProcessStartInfo startInfo, string scriptName, string scriptsFullPath) { - public string ExecutableName { get; } = executableName; public ProcessStartInfo StartInfo { get; } = startInfo; + public string ScriptName { get; } = scriptName; + public string ScriptsFullPath { get; } = scriptsFullPath; } } } - -#endif diff --git a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj index d83b9a6b34b..381cffe049f 100644 --- a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj +++ b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj @@ -48,7 +48,6 @@ - - + \ No newline at end of file diff --git a/src/Tasks/Microsoft.Build.Tasks.csproj b/src/Tasks/Microsoft.Build.Tasks.csproj index 5bdaff55739..76c117cf103 100644 --- a/src/Tasks/Microsoft.Build.Tasks.csproj +++ b/src/Tasks/Microsoft.Build.Tasks.csproj @@ -433,12 +433,6 @@ PreserveNewest - - - PreserveNewest - Current\Microsoft.Common.props - PreserveNewest diff --git a/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj b/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj index 4a254efc218..dafe0d10bcf 100644 --- a/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj +++ b/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj @@ -35,7 +35,7 @@ - $(ArtifactsBinDir)bootstrap\$(TargetFramework.ToLowerInvariant()) + $(ArtifactsBinDir)bootstrap\core From cb5dd945d3fee1661dee10873316a898391d3241 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Thu, 11 Jul 2024 21:29:42 +0200 Subject: [PATCH 18/27] use Task as a base class --- .../Tasks/InstallDotNetCoreTask.cs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs index 409d213f7e2..293c3e3820f 100644 --- a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -16,7 +16,7 @@ namespace MSBuild.Bootstrap.Utils.Tasks /// This task is designed to automate the installation of .NET Core SDK. /// It downloads the appropriate installation script and executes it to install the specified version of .NET Core SDK. /// - public sealed class InstallDotNetCoreTask : ToolTask + public sealed class InstallDotNetCoreTask : Task { private const string ScriptName = "dotnet-install"; @@ -55,8 +55,6 @@ public InstallDotNetCoreTask() private bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); - protected override string ToolName => IsWindows ? "powershell.exe" : "/bin/bash"; - /// /// Executes the task, downloading and running the .NET Core installation script. /// @@ -80,8 +78,6 @@ public override bool Execute() return RunScript(executionSettings); } - protected override string GenerateFullPathToTool() => ToolName; - /// /// Downloads the .NET Core installation script asynchronously from the specified URL. /// @@ -193,7 +189,7 @@ private ScriptExecutionSettings SetupScriptsExecutionSettings() var startInfo = new ProcessStartInfo { - FileName = ToolName, + FileName = IsWindows ? "powershell.exe" : "/bin/bash", Arguments = scriptArgs, RedirectStandardOutput = true, RedirectStandardError = true, From 5b45a2b3a1962e10ba8d99e510c1a8859d279134 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Thu, 11 Jul 2024 22:16:14 +0200 Subject: [PATCH 19/27] onboard tooltask in InstallDotNetCoreTask --- .../Tasks/InstallDotNetCoreTask.cs | 77 ++++--------------- 1 file changed, 17 insertions(+), 60 deletions(-) diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs index 293c3e3820f..c0b42f373b5 100644 --- a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -1,7 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using System.Diagnostics; using System.IO; using System.Net.Http; using System.Runtime.InteropServices; @@ -16,7 +15,7 @@ namespace MSBuild.Bootstrap.Utils.Tasks /// This task is designed to automate the installation of .NET Core SDK. /// It downloads the appropriate installation script and executes it to install the specified version of .NET Core SDK. /// - public sealed class InstallDotNetCoreTask : Task + public sealed class InstallDotNetCoreTask : ToolTask { private const string ScriptName = "dotnet-install"; @@ -55,6 +54,8 @@ public InstallDotNetCoreTask() private bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + protected override string ToolName => IsWindows ? "powershell.exe" : "/bin/bash"; + /// /// Executes the task, downloading and running the .NET Core installation script. /// @@ -78,6 +79,8 @@ public override bool Execute() return RunScript(executionSettings); } + protected override string GenerateFullPathToTool() => ToolName; + /// /// Downloads the .NET Core installation script asynchronously from the specified URL. /// @@ -109,31 +112,12 @@ private async AsyncTasks.Task DownloadScriptAsync(string scriptName, string scri /// The path of the script to make executable. private void MakeScriptExecutable(string scriptPath) { - if (IsWindows) - { - return; - } - - using (var process = new Process + if (!IsWindows) { - StartInfo = new ProcessStartInfo + int exitCode = ExecuteTool("/bin/chmod", string.Empty, $"+x {scriptPath}"); + if (exitCode != 0) { - FileName = "/bin/chmod", - Arguments = $"+x {scriptPath}", - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true, - }, - }) - { - _ = process.Start(); - process.WaitForExit(); - - if (process.ExitCode != 0) - { - string errors = process.StandardError.ReadToEnd() ?? string.Empty; - Log.LogError($"Install-scripts can not be made executable due to the errors: {errors}."); + Log.LogError($"Install-scripts can not be made executable due to the errors reported above."); } } } @@ -145,30 +129,13 @@ private void MakeScriptExecutable(string scriptPath) /// True if the script executed successfully; otherwise, false. private bool RunScript(ScriptExecutionSettings executionSettings) { - if (Log.HasLoggedErrors) - { - return false; - } - - using (Process process = new Process { StartInfo = executionSettings.StartInfo }) + if (!Log.HasLoggedErrors) { - bool started = process.Start(); - if (started) - { - string output = process.StandardOutput.ReadToEnd() ?? string.Empty; - Log.LogMessage($"Install-scripts output logs: {output}"); - - process.WaitForExit(); + int exitCode = ExecuteTool(ToolName, string.Empty, executionSettings.ExecutableArgs); - if (process.ExitCode != 0) - { - string errors = process.StandardError.ReadToEnd() ?? string.Empty; - Log.LogError($"Install-scripts execution errors: {errors}"); - } - } - else + if (exitCode != 0) { - Log.LogError("Process for install-scripts execution has not started."); + Log.LogError($"Install-scripts was not executed successfully."); } } @@ -187,29 +154,19 @@ private ScriptExecutionSettings SetupScriptsExecutionSettings() ? $"-NoProfile -ExecutionPolicy Bypass -File {scriptPath} -Version {Version} -InstallDir {InstallDir}" : $"{scriptPath} --version {Version} --install-dir {InstallDir}"; - var startInfo = new ProcessStartInfo - { - FileName = IsWindows ? "powershell.exe" : "/bin/bash", - Arguments = scriptArgs, - RedirectStandardOutput = true, - RedirectStandardError = true, - UseShellExecute = false, - CreateNoWindow = true, - }; - - return new ScriptExecutionSettings(startInfo, $"{ScriptName}.{scriptExtension}", scriptPath); + return new ScriptExecutionSettings($"{ScriptName}.{scriptExtension}", scriptPath, scriptArgs); } /// /// A private struct to hold settings for script execution. /// - private struct ScriptExecutionSettings(ProcessStartInfo startInfo, string scriptName, string scriptsFullPath) + private readonly struct ScriptExecutionSettings(string scriptName, string scriptsFullPath, string executableArgs) { - public ProcessStartInfo StartInfo { get; } = startInfo; - public string ScriptName { get; } = scriptName; public string ScriptsFullPath { get; } = scriptsFullPath; + + public string ExecutableArgs { get; } = executableArgs; } } } From 5852b3d778362105203ac4e550fd9456028627c5 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Fri, 12 Jul 2024 16:54:36 +0200 Subject: [PATCH 20/27] fix review comments --- documentation/release-checklist.md | 2 +- eng/cibuild_bootstrapped_msbuild.ps1 | 2 +- eng/cibuild_bootstrapped_msbuild.sh | 2 +- src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/documentation/release-checklist.md b/documentation/release-checklist.md index 3ae646c436c..34a19fc0e75 100644 --- a/documentation/release-checklist.md +++ b/documentation/release-checklist.md @@ -56,7 +56,7 @@ https://ceapex.visualstudio.com/CEINTL/_workitems/edit/957875 (DONE) - [ ] Get M2 or QB approval as necessary per the VS schedule - [ ] Merge to VS (babysit the automatically generated VS insertion PR https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequests for the MSBuild commit noted in above step): {{URL_OF_VS_INSERTION}} - [ ] Update the PackageValidationBaselineVersion to the latest released version ({{THIS_RELEASE_VERSION}}.0) - this might require temporary addition of the [build artifacts feed](https://github.com/dotnet/msbuild/blob/29397b577e3ec0fe0c7650c3ab0400909655dc88/NuGet.config#L9) as the new version is not yet added to the official feeds (this is post release). This can trigger a high severity CG error (https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/secure-supply-chain/how-to-securely-configure-package-source-files) - however it should be fine to keep this temporary feed untill the release. -- [ ] Update the requested SDK version for bootstrap folder if a fresh sdk was released in [NetVersion](https://github.com/dotnet/msbuild/blob/main/eng/BootStrapMsBuild.props). +- [ ] Update the requested SDK version for bootstrap folder (the `NetVersion` property in [BootStrapMsBuild.props](https://github.com/dotnet/msbuild/blob/main/eng/BootStrapMsBuild.props)) and buildToolCommand/_InitializeBuildToolCommand values in cibuild_bootstrapped_msbuild scripts if a fresh sdk was released (released runtimes and associated sdk versions can be checked here - https://dotnet.microsoft.com/en-us/download/visual-studio-sdks - make sure to allways check the details of the appropriate targetted version of .NET for the matchin latest version of SDK). ## ASAP On/After GA: diff --git a/eng/cibuild_bootstrapped_msbuild.ps1 b/eng/cibuild_bootstrapped_msbuild.ps1 index 22bbf5dd3f1..7328809b844 100644 --- a/eng/cibuild_bootstrapped_msbuild.ps1 +++ b/eng/cibuild_bootstrapped_msbuild.ps1 @@ -85,7 +85,7 @@ try { else { $buildToolPath = Join-Path $bootstrapRoot "core\dotnet.exe" - $buildToolCommand = "msbuild"; + $buildToolCommand = Join-Path $bootstrapRoot "core\sdk\8.0.302\MSBuild.dll"; $buildToolFramework = "net8.0" } diff --git a/eng/cibuild_bootstrapped_msbuild.sh b/eng/cibuild_bootstrapped_msbuild.sh index 2539d025c26..9ac9b82fc02 100755 --- a/eng/cibuild_bootstrapped_msbuild.sh +++ b/eng/cibuild_bootstrapped_msbuild.sh @@ -59,7 +59,7 @@ bootstrapRoot="$Stage1Dir/bin/bootstrap" if [ $host_type = "core" ] then _InitializeBuildTool="$bootstrapRoot/core/dotnet" - _InitializeBuildToolCommand="build" + _InitializeBuildToolCommand="$bootstrapRoot/core/sdk/8.0.302/MSBuild.dll" _InitializeBuildToolFramework="net8.0" else echo "Unsupported hostType ($host_type)" diff --git a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs index c0b42f373b5..0eda643f491 100644 --- a/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs +++ b/src/MSBuild.Bootstrap.Utils/Tasks/InstallDotNetCoreTask.cs @@ -62,7 +62,7 @@ public InstallDotNetCoreTask() /// True if the task succeeded; otherwise, false. public override bool Execute() { - if (Directory.Exists(InstallDir) || Directory.Exists(Path.Combine(InstallDir, "sdk", Version))) + if (Directory.Exists(Path.Combine(InstallDir, "sdk", Version))) { // no need to download sdk again, it exists locally return true; From c0b6b35202e97ce749f6fc4e987a556d51e80bee Mon Sep 17 00:00:00 2001 From: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com> Date: Fri, 12 Jul 2024 18:00:30 +0200 Subject: [PATCH 21/27] cleanup --- eng/cibuild_bootstrapped_msbuild.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/cibuild_bootstrapped_msbuild.ps1 b/eng/cibuild_bootstrapped_msbuild.ps1 index 7328809b844..0aec2bbde1b 100644 --- a/eng/cibuild_bootstrapped_msbuild.ps1 +++ b/eng/cibuild_bootstrapped_msbuild.ps1 @@ -85,7 +85,7 @@ try { else { $buildToolPath = Join-Path $bootstrapRoot "core\dotnet.exe" - $buildToolCommand = Join-Path $bootstrapRoot "core\sdk\8.0.302\MSBuild.dll"; + $buildToolCommand = Join-Path $bootstrapRoot "core\sdk\8.0.302\MSBuild.dll" $buildToolFramework = "net8.0" } From 9be76bcb1e1a29631a917a984b9681de7f87c375 Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Wed, 17 Jul 2024 12:55:02 -0500 Subject: [PATCH 22/27] InstallDotNetCoreTask via RoslynCodeTaskFactory This avoids ever having to block on building the task. I'm leaving the project in place for easier editing, but not including it in the `.sln` so it won't be part of any build--you'd have to open it individually to get a great inner-loop experience with the task. --- MSBuild.sln | 26 -------------------------- eng/BootStrapMsBuild.targets | 8 +++++++- 2 files changed, 7 insertions(+), 27 deletions(-) diff --git a/MSBuild.sln b/MSBuild.sln index 1669e3821ca..258d1a5c5d7 100644 --- a/MSBuild.sln +++ b/MSBuild.sln @@ -84,8 +84,6 @@ 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 @@ -918,30 +916,6 @@ 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 diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index a33110623e1..872b5744e7d 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -203,7 +203,13 @@ - + + + + + From d0c2057ec536c30a01d566efefba48a3c81f60ff Mon Sep 17 00:00:00 2001 From: Rainer Sigwald Date: Wed, 17 Jul 2024 13:21:21 -0500 Subject: [PATCH 23/27] Acquire SDK earlier Pushing this lengthy process before `ResolveProjectReferences` means it's more likely to be able to be scheduled and finish without being on the critical path through builds. --- eng/BootStrapMsBuild.targets | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index 872b5744e7d..f73d06764dc 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -210,7 +210,9 @@ - + $(ArtifactsBinDir)bootstrap\core\ @@ -219,7 +221,7 @@ - + From 9610b1dbccccf29ce19fcd8e99dfd4b457af53c6 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova <95473390+YuliiaKovalova@users.noreply.github.com> Date: Wed, 17 Jul 2024 22:17:19 +0200 Subject: [PATCH 24/27] update documentation Co-authored-by: Rainer Sigwald --- documentation/release-checklist.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/documentation/release-checklist.md b/documentation/release-checklist.md index 34a19fc0e75..7c991d446e3 100644 --- a/documentation/release-checklist.md +++ b/documentation/release-checklist.md @@ -56,7 +56,7 @@ https://ceapex.visualstudio.com/CEINTL/_workitems/edit/957875 (DONE) - [ ] Get M2 or QB approval as necessary per the VS schedule - [ ] Merge to VS (babysit the automatically generated VS insertion PR https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequests for the MSBuild commit noted in above step): {{URL_OF_VS_INSERTION}} - [ ] Update the PackageValidationBaselineVersion to the latest released version ({{THIS_RELEASE_VERSION}}.0) - this might require temporary addition of the [build artifacts feed](https://github.com/dotnet/msbuild/blob/29397b577e3ec0fe0c7650c3ab0400909655dc88/NuGet.config#L9) as the new version is not yet added to the official feeds (this is post release). This can trigger a high severity CG error (https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/secure-supply-chain/how-to-securely-configure-package-source-files) - however it should be fine to keep this temporary feed untill the release. -- [ ] Update the requested SDK version for bootstrap folder (the `NetVersion` property in [BootStrapMsBuild.props](https://github.com/dotnet/msbuild/blob/main/eng/BootStrapMsBuild.props)) and buildToolCommand/_InitializeBuildToolCommand values in cibuild_bootstrapped_msbuild scripts if a fresh sdk was released (released runtimes and associated sdk versions can be checked here - https://dotnet.microsoft.com/en-us/download/visual-studio-sdks - make sure to allways check the details of the appropriate targetted version of .NET for the matchin latest version of SDK). +- [ ] Update the requested SDK version for bootstrap folder (the `NetVersion` property in [BootStrapMsBuild.props](https://github.com/dotnet/msbuild/blob/main/eng/BootStrapMsBuild.props)) and buildToolCommand/_InitializeBuildToolCommand values in cibuild_bootstrapped_msbuild scripts if a fresh sdk was released (released runtimes and associated sdk versions can be checked here - https://dotnet.microsoft.com/en-us/download/visual-studio-sdks - make sure to always check the details of the appropriate targeted version of .NET for the matching latest version of SDK). ## ASAP On/After GA: From b5700431a0b45d58217cbf117484f4171b0ed880 Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Thu, 18 Jul 2024 15:04:37 +0200 Subject: [PATCH 25/27] move BootstrapSdkVersion to Versions.props --- documentation/release-checklist.md | 2 +- eng/BootStrapMsBuild.props | 4 ---- eng/BootStrapMsBuild.targets | 6 +++--- eng/Versions.props | 5 +++++ eng/cibuild_bootstrapped_msbuild.ps1 | 1 + eng/cibuild_bootstrapped_msbuild.sh | 1 + src/UnitTests.Shared/BootstrapLocationAttribute.cs | 4 ++-- .../Microsoft.Build.UnitTests.Shared.csproj | 2 +- src/UnitTests.Shared/RunnerUtilities.cs | 2 +- 9 files changed, 15 insertions(+), 12 deletions(-) diff --git a/documentation/release-checklist.md b/documentation/release-checklist.md index 7c991d446e3..72b1e87cbf9 100644 --- a/documentation/release-checklist.md +++ b/documentation/release-checklist.md @@ -56,7 +56,7 @@ https://ceapex.visualstudio.com/CEINTL/_workitems/edit/957875 (DONE) - [ ] Get M2 or QB approval as necessary per the VS schedule - [ ] Merge to VS (babysit the automatically generated VS insertion PR https://devdiv.visualstudio.com/DevDiv/_git/VS/pullrequests for the MSBuild commit noted in above step): {{URL_OF_VS_INSERTION}} - [ ] Update the PackageValidationBaselineVersion to the latest released version ({{THIS_RELEASE_VERSION}}.0) - this might require temporary addition of the [build artifacts feed](https://github.com/dotnet/msbuild/blob/29397b577e3ec0fe0c7650c3ab0400909655dc88/NuGet.config#L9) as the new version is not yet added to the official feeds (this is post release). This can trigger a high severity CG error (https://eng.ms/docs/cloud-ai-platform/devdiv/one-engineering-system-1es/1es-docs/secure-supply-chain/how-to-securely-configure-package-source-files) - however it should be fine to keep this temporary feed untill the release. -- [ ] Update the requested SDK version for bootstrap folder (the `NetVersion` property in [BootStrapMsBuild.props](https://github.com/dotnet/msbuild/blob/main/eng/BootStrapMsBuild.props)) and buildToolCommand/_InitializeBuildToolCommand values in cibuild_bootstrapped_msbuild scripts if a fresh sdk was released (released runtimes and associated sdk versions can be checked here - https://dotnet.microsoft.com/en-us/download/visual-studio-sdks - make sure to always check the details of the appropriate targeted version of .NET for the matching latest version of SDK). +- [ ] Update the requested SDK version for bootstrap folder (the `BootstrapSdkVersion` property in [Versions.props](https://github.com/dotnet/msbuild/blob/main/eng/Versions.props)) and buildToolCommand/_InitializeBuildToolCommand values in cibuild_bootstrapped_msbuild scripts if a fresh sdk was released (released runtimes and associated sdk versions can be checked here - https://dotnet.microsoft.com/en-us/download/visual-studio-sdks - make sure to always check the details of the appropriate targeted version of .NET for the matching latest version of SDK). ## ASAP On/After GA: diff --git a/eng/BootStrapMsBuild.props b/eng/BootStrapMsBuild.props index f38de56f1ad..3dd91450e88 100644 --- a/eng/BootStrapMsBuild.props +++ b/eng/BootStrapMsBuild.props @@ -2,10 +2,6 @@ - - 8.0.302 - - $(ArtifactsBinDir)bootstrap\ $(BootstrapDestination)$(Platform)\ diff --git a/eng/BootStrapMsBuild.targets b/eng/BootStrapMsBuild.targets index f73d06764dc..8cacf1da906 100644 --- a/eng/BootStrapMsBuild.targets +++ b/eng/BootStrapMsBuild.targets @@ -218,7 +218,7 @@ $(ArtifactsBinDir)bootstrap\core\ - + @@ -230,11 +230,11 @@ + DestinationFiles="@(FreshlyBuiltNetBinaries->'$(InstallDir)sdk\$(BootstrapSdkVersion)\%(RecursiveDir)%(Filename)%(Extension)')" /> diff --git a/eng/Versions.props b/eng/Versions.props index 3791705e717..31d2e937f81 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -55,6 +55,11 @@ 6.11.0-rc.122 6.0.0 + + + 8.0.302 + + + From 5cfef7b3817f0a95749137aa0e8e6acf098bdb6d Mon Sep 17 00:00:00 2001 From: YuliiaKovalova Date: Tue, 30 Jul 2024 12:08:53 +0200 Subject: [PATCH 27/27] undo extra changes --- src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj index 381cffe049f..1d116d117d2 100644 --- a/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj +++ b/src/MSBuild.Bootstrap/MSBuild.Bootstrap.csproj @@ -18,7 +18,6 @@ - @@ -48,6 +47,7 @@ + \ No newline at end of file