diff --git a/eng/Version.Details.xml b/eng/Version.Details.xml index 4cba23d2b50..078aadacd4e 100644 --- a/eng/Version.Details.xml +++ b/eng/Version.Details.xml @@ -123,19 +123,19 @@ - + https://github.com/dotnet/arcade - ab5773ac30dce73227fa1dff6bf1a21eea67cbd0 + c85f9aceddaf85296e3efbc463daaa34fef5a375 - + https://github.com/dotnet/arcade - ab5773ac30dce73227fa1dff6bf1a21eea67cbd0 + c85f9aceddaf85296e3efbc463daaa34fef5a375 - + https://github.com/dotnet/arcade - ab5773ac30dce73227fa1dff6bf1a21eea67cbd0 + c85f9aceddaf85296e3efbc463daaa34fef5a375 https://github.com/nuget/nuget.client @@ -150,9 +150,9 @@ 46223204b646f96104bac46f9dfa4959da9d86ac - + https://github.com/dotnet/arcade - ab5773ac30dce73227fa1dff6bf1a21eea67cbd0 + c85f9aceddaf85296e3efbc463daaa34fef5a375 diff --git a/eng/Versions.props b/eng/Versions.props index b4aafb3b87e..ae236303520 100644 --- a/eng/Versions.props +++ b/eng/Versions.props @@ -2,7 +2,7 @@ - 17.14.42 + 17.14.43 release 17.13.9 15.1.0.0 @@ -72,7 +72,7 @@ Otherwise, this version of dotnet will not be installed and the build will error out. --> $([System.Text.RegularExpressions.Regex]::Match($([System.IO.File]::ReadAllText('$(MSBuildThisFileDirectory)..\global.json')), '"dotnet": "([^"]*)"').Groups.get_Item(1)) 4.2.0-1.22102.8 - 9.0.0-beta.25626.6 + 9.0.0-beta.26063.2 4.14.0-3.25157.4 6.14.0-rc.116 diff --git a/eng/common/core-templates/job/publish-build-assets.yml b/eng/common/core-templates/job/publish-build-assets.yml index 6b5ff28cc70..3cb20fb5041 100644 --- a/eng/common/core-templates/job/publish-build-assets.yml +++ b/eng/common/core-templates/job/publish-build-assets.yml @@ -74,7 +74,7 @@ jobs: # If it's not devdiv, it's dnceng ${{ if ne(variables['System.TeamProject'], 'DevDiv') }}: name: NetCore1ESPool-Publishing-Internal - image: windows.vs2019.amd64 + image: windows.vs2022.amd64 os: windows steps: - ${{ if eq(parameters.is1ESPipeline, '') }}: diff --git a/eng/common/core-templates/post-build/post-build.yml b/eng/common/core-templates/post-build/post-build.yml index 221d1ac6de1..864427d9694 100644 --- a/eng/common/core-templates/post-build/post-build.yml +++ b/eng/common/core-templates/post-build/post-build.yml @@ -291,11 +291,11 @@ stages: ${{ else }}: ${{ if eq(parameters.is1ESPipeline, true) }}: name: NetCore1ESPool-Publishing-Internal - image: windows.vs2019.amd64 + image: windows.vs2022.amd64 os: windows ${{ else }}: name: NetCore1ESPool-Publishing-Internal - demands: ImageOverride -equals windows.vs2019.amd64 + demands: ImageOverride -equals windows.vs2022.amd64 steps: - template: /eng/common/core-templates/post-build/setup-maestro-vars.yml parameters: diff --git a/eng/common/templates/variables/pool-providers.yml b/eng/common/templates/variables/pool-providers.yml index e0b19c14a07..18693ea120d 100644 --- a/eng/common/templates/variables/pool-providers.yml +++ b/eng/common/templates/variables/pool-providers.yml @@ -23,7 +23,7 @@ # # pool: # name: $(DncEngInternalBuildPool) -# demands: ImageOverride -equals windows.vs2019.amd64 +# demands: ImageOverride -equals windows.vs2022.amd64 variables: - ${{ if eq(variables['System.TeamProject'], 'internal') }}: - template: /eng/common/templates-official/variables/pool-providers.yml diff --git a/global.json b/global.json index 331ce6b6f7d..1eb516a34d0 100644 --- a/global.json +++ b/global.json @@ -10,6 +10,6 @@ "xcopy-msbuild": "17.12.0" }, "msbuild-sdks": { - "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.25626.6" + "Microsoft.DotNet.Arcade.Sdk": "9.0.0-beta.26063.2" } } diff --git a/src/Build.UnitTests/ProjectCache/ProjectCacheTests.cs b/src/Build.UnitTests/ProjectCache/ProjectCacheTests.cs index 449bdf1401d..e0cd9095470 100644 --- a/src/Build.UnitTests/ProjectCache/ProjectCacheTests.cs +++ b/src/Build.UnitTests/ProjectCache/ProjectCacheTests.cs @@ -10,12 +10,12 @@ using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; -using Microsoft.Build.CommandLine; using Microsoft.Build.Construction; using Microsoft.Build.Execution; using Microsoft.Build.Experimental.ProjectCache; using Microsoft.Build.Framework; using Microsoft.Build.Graph; +using Microsoft.Build.Internal; using Microsoft.Build.Shared; using Microsoft.Build.Unittest; using Microsoft.Build.UnitTests; @@ -24,13 +24,14 @@ using Shouldly; using Xunit; using Xunit.Abstractions; -using Xunit.Sdk; using Task = System.Threading.Tasks.Task; namespace Microsoft.Build.Engine.UnitTests.ProjectCache { public class ProjectCacheTests : IDisposable { + private static string s_currentTargetNETFramework = $"net{RunnerUtilities.BootstrapSdkVersion.Split('.')?.FirstOrDefault()}.0"; + public ProjectCacheTests(ITestOutputHelper output) { _output = output; @@ -47,22 +48,37 @@ public void Dispose() private const string AssemblyMockCache = nameof(AssemblyMockCache); - private static readonly Lazy SamplePluginAssemblyPath = + private const string Configuration = +#if DEBUG + "Debug"; +#else + "Release"; +#endif + + private static readonly string s_currentFramework = GetCurrentFramework(); + + private static string GetCurrentFramework() => +#if RUNTIME_TYPE_NETCORE + s_currentTargetNETFramework; +#else + "net472"; +#endif + + private static readonly string s_samplePluginPath = Path.Combine( + BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory, + "..", + "..", + "..", + "Samples", + "ProjectCachePlugin"); + + private static readonly Lazy s_samplePluginAssemblyPath = new Lazy( - () => - { - return Directory.EnumerateFiles( - Path.GetFullPath( - Path.Combine( - BuildEnvironmentHelper.Instance.CurrentMSBuildToolsDirectory, - "..", - "..", - "..", - "Samples", - "ProjectCachePlugin")), - "ProjectCachePlugin.dll", - SearchOption.AllDirectories).First(); - }); + () => Path.Combine( + Path.GetFullPath(s_samplePluginPath), + Configuration, + s_currentFramework, + "ProjectCachePlugin.dll")); public class GraphCacheResponse { @@ -74,7 +90,7 @@ public class GraphCacheResponse @$" - <{ItemTypeNames.ProjectCachePlugin} Include=`{SamplePluginAssemblyPath.Value}` /> + <{ItemTypeNames.ProjectCachePlugin} Include=`{s_samplePluginAssemblyPath.Value}` /> @@ -919,7 +935,7 @@ public void CacheViaBuildParametersCanDiscoverAndLoadPluginFromAssembly() var buildParameters = new BuildParameters { - ProjectCacheDescriptor = ProjectCacheDescriptor.FromAssemblyPath(SamplePluginAssemblyPath.Value) + ProjectCacheDescriptor = ProjectCacheDescriptor.FromAssemblyPath(s_samplePluginAssemblyPath.Value) }; MockLogger logger; @@ -1029,7 +1045,7 @@ public void MultiplePlugins() }, extraContentForAllNodes: @$" - <{ItemTypeNames.ProjectCachePlugin} Include='{SamplePluginAssemblyPath.Value}' /> + <{ItemTypeNames.ProjectCachePlugin} Include='{s_samplePluginAssemblyPath.Value}' /> "); var mockCache = new InstanceMockCache(); @@ -1065,7 +1081,7 @@ public void NotAllNodesDefineAPlugin() 2, @$" - <{ItemTypeNames.ProjectCachePlugin} Include='{SamplePluginAssemblyPath.Value}' /> + <{ItemTypeNames.ProjectCachePlugin} Include='{s_samplePluginAssemblyPath.Value}' /> " } @@ -1127,7 +1143,7 @@ public void EngineShouldHandleExceptionsFromCachePluginViaBuildParameters(ErrorL new BuildParameters { UseSynchronousLogging = true, - ProjectCacheDescriptor = ProjectCacheDescriptor.FromAssemblyPath(SamplePluginAssemblyPath.Value) + ProjectCacheDescriptor = ProjectCacheDescriptor.FromAssemblyPath(s_samplePluginAssemblyPath.Value) }); logger = buildSession.Logger; @@ -1237,7 +1253,7 @@ public void EngineShouldHandleExceptionsFromCachePluginViaGraphBuild(ErrorLocati }, extraContentForAllNodes: @$" - <{ItemTypeNames.ProjectCachePlugin} Include=`{SamplePluginAssemblyPath.Value}` /> + <{ItemTypeNames.ProjectCachePlugin} Include=`{s_samplePluginAssemblyPath.Value}` /> <{ItemTypeNames.ProjectReferenceTargets} Include=`Build` Targets=`Build` /> @@ -1332,7 +1348,7 @@ public void EndBuildShouldGetCalledOnceWhenItThrowsExceptionsFromGraphBuilds() @$" - <{ItemTypeNames.ProjectCachePlugin} Include=`{SamplePluginAssemblyPath.Value}` /> + <{ItemTypeNames.ProjectCachePlugin} Include=`{s_samplePluginAssemblyPath.Value}` /> @@ -1668,10 +1684,10 @@ public void EmbeddedResourcesFileCompileCache() { var directory = _env.CreateFolder(); string content = ObjectModelHelpers.CleanupFileContents( - """ + $""" - net8.0 + {s_currentTargetNETFramework} Exe bin/ @@ -1681,7 +1697,8 @@ public void EmbeddedResourcesFileCompileCache() """); var projectPath = directory.CreateFile("app.csproj", content).Path; - directory.CreateFile("Program.cs", + directory.CreateFile( + "Program.cs", """ using System; using System.IO; @@ -1715,7 +1732,11 @@ static void Main() // Build and run the project string output = RunnerUtilities.ExecBootstrapedMSBuild($"{projectPath} -restore", out bool success); success.ShouldBeTrue(output); - output = RunnerUtilities.RunProcessAndGetOutput(Path.Combine(directory.Path, "bin/net8.0/app"), "", out success, false, _output); + string bootstrapCorePath = Path.Combine(RunnerUtilities.BootstrapRootPath, "core", NativeMethodsShared.IsWindows ? "dotnet.exe" : "dotnet"); + + // Use dotnet exec instead of running the exe directly to ensure using the bootstrap's runtime (which may be newer than the installed one) + string appDllPath = Path.Combine(directory.Path, $"bin/{s_currentTargetNETFramework}/app.dll"); + output = RunnerUtilities.RunProcessAndGetOutput(bootstrapCorePath, $"exec \"{appDllPath}\"", out success, false, _output); output.ShouldContain("A=1"); output.ShouldContain("B=1"); @@ -1723,7 +1744,8 @@ static void Main() FileUtilities.DeleteNoThrow(file1.Path); output = RunnerUtilities.ExecBootstrapedMSBuild($"{projectPath}", out success); success.ShouldBeTrue(output); - output = RunnerUtilities.RunProcessAndGetOutput(Path.Combine(directory.Path, "bin/net8.0/app"), "", out success, false, _output); + + output = RunnerUtilities.RunProcessAndGetOutput(bootstrapCorePath, $"exec \"{appDllPath}\"", out success, false, _output); output.ShouldNotContain("A=1"); output.ShouldContain("B=1"); } diff --git a/src/UnitTests.Shared/BootstrapLocationAttribute.cs b/src/UnitTests.Shared/BootstrapLocationAttribute.cs index 7dfeb62ce64..3854f1ecf13 100644 --- a/src/UnitTests.Shared/BootstrapLocationAttribute.cs +++ b/src/UnitTests.Shared/BootstrapLocationAttribute.cs @@ -6,9 +6,20 @@ namespace Microsoft.Build.UnitTests.Shared; [System.AttributeUsage(System.AttributeTargets.Assembly)] -internal sealed class BootstrapLocationAttribute(string bootstrapMsBuildBinaryLocation, string bootstrapSdkVersion) : System.Attribute +internal sealed class BootstrapLocationAttribute(string bootstrapRoot, string bootstrapMsBuildBinaryLocation, string bootstrapSdkVersion) : System.Attribute { + /// + /// Path to the root of the bootstrap MSBuild (in artifacts folder). + /// + public string BootstrapRoot { get; } = bootstrapRoot; + + /// + /// Resolves path to MSBuild.exe or MSBuild.dll, depending on the runtime. + /// public string BootstrapMsBuildBinaryLocation { get; } = bootstrapMsBuildBinaryLocation; + /// + /// Returns the version of the SDK used by the bootstrap MSBuild. + /// public string BootstrapSdkVersion { get; } = bootstrapSdkVersion; } diff --git a/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj b/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj index 320bbc4f596..a17ead42a77 100644 --- a/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj +++ b/src/UnitTests.Shared/Microsoft.Build.UnitTests.Shared.csproj @@ -40,8 +40,9 @@ - <_Parameter1>$(TestBootstrapBinaryDestination) - <_Parameter2>$(BootstrapSdkVersion) + <_Parameter1>$(ArtifactsBinDir)bootstrap + <_Parameter2>$(TestBootstrapBinaryDestination) + <_Parameter3>$(BootstrapSdkVersion) diff --git a/src/UnitTests.Shared/RunnerUtilities.cs b/src/UnitTests.Shared/RunnerUtilities.cs index e0879c00028..e3f632fae10 100644 --- a/src/UnitTests.Shared/RunnerUtilities.cs +++ b/src/UnitTests.Shared/RunnerUtilities.cs @@ -20,6 +20,14 @@ public static class RunnerUtilities public static ArtifactsLocationAttribute ArtifactsLocationAttribute = Assembly.GetExecutingAssembly().GetCustomAttribute() ?? throw new InvalidOperationException("This test assembly does not have the ArtifactsLocationAttribute"); + + public static string BootstrapRootPath => BootstrapLocationAttribute.BootstrapRoot; + + public static string BootstrapSdkVersion => BootstrapLocationAttribute.BootstrapSdkVersion; + + internal static BootstrapLocationAttribute BootstrapLocationAttribute = Assembly.GetExecutingAssembly().GetCustomAttribute() + ?? throw new InvalidOperationException("This test assembly does not have the BootstrapLocationAttribute"); + #if !FEATURE_RUN_EXE_IN_TESTS private static readonly string s_dotnetExePath = EnvironmentProvider.GetDotnetExePath();