From c9b29439b0ed806c5c7cd7912d777a42f14c32b0 Mon Sep 17 00:00:00 2001 From: David Barbet Date: Thu, 11 Jan 2024 16:36:08 -0800 Subject: [PATCH 1/3] Include buildhost deps.json --- ...eAnalysis.Workspaces.MSBuild.BuildHost.csproj | 16 ++++++++++++---- ...rosoft.CodeAnalysis.Workspaces.MSBuild.csproj | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Workspaces/Core/MSBuild.BuildHost/Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.csproj b/src/Workspaces/Core/MSBuild.BuildHost/Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.csproj index 2683f6c3df27b..4d0e5b8180a5b 100644 --- a/src/Workspaces/Core/MSBuild.BuildHost/Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.csproj +++ b/src/Workspaces/Core/MSBuild.BuildHost/Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.csproj @@ -54,8 +54,16 @@ - - - <_UseBuildDependencyFile>true - + + + + + + $(ProjectDepsFileName) + + + diff --git a/src/Workspaces/Core/MSBuild/Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj b/src/Workspaces/Core/MSBuild/Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj index 69ec25634df59..2d7ef0d9a1969 100644 --- a/src/Workspaces/Core/MSBuild/Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj +++ b/src/Workspaces/Core/MSBuild/Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj @@ -117,7 +117,7 @@ - + From 3dab493ba891330523c77b3e9a547fa4f68b1716 Mon Sep 17 00:00:00 2001 From: Jason Malinowski Date: Fri, 12 Jan 2024 16:56:38 -0800 Subject: [PATCH 2/3] Add a test that the deps.json is correctly deployed --- .../Core/MSBuild/MSBuild/BuildHostProcessManager.cs | 9 +++++++-- src/Workspaces/MSBuildTest/NetCoreTests.cs | 7 +++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Workspaces/Core/MSBuild/MSBuild/BuildHostProcessManager.cs b/src/Workspaces/Core/MSBuild/MSBuild/BuildHostProcessManager.cs index a893b4d260b21..3ed2d6dbe8c5d 100644 --- a/src/Workspaces/Core/MSBuild/MSBuild/BuildHostProcessManager.cs +++ b/src/Workspaces/Core/MSBuild/MSBuild/BuildHostProcessManager.cs @@ -162,8 +162,7 @@ private ProcessStartInfo CreateDotNetCoreBuildHostStartInfo() AddArgument(processStartInfo, "--roll-forward"); AddArgument(processStartInfo, "LatestMajor"); - // The .NET Core build host is deployed as a content folder next to the application into the BuildHost-netcore path - var netCoreBuildHostPath = Path.Combine(Path.GetDirectoryName(typeof(BuildHostProcessManager).Assembly.Location)!, "BuildHost-netcore", "Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll"); + var netCoreBuildHostPath = GetNetCoreBuildHostPath(); AddArgument(processStartInfo, netCoreBuildHostPath); @@ -172,6 +171,12 @@ private ProcessStartInfo CreateDotNetCoreBuildHostStartInfo() return processStartInfo; } + internal static string GetNetCoreBuildHostPath() + { + // The .NET Core build host is deployed as a content folder next to the application into the BuildHost-netcore path + return Path.Combine(Path.GetDirectoryName(typeof(BuildHostProcessManager).Assembly.Location)!, "BuildHost-netcore", "Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.dll"); + } + private ProcessStartInfo CreateDotNetFrameworkBuildHostStartInfo() { var netFrameworkBuildHost = GetPathToDotNetFrameworkBuildHost(); diff --git a/src/Workspaces/MSBuildTest/NetCoreTests.cs b/src/Workspaces/MSBuildTest/NetCoreTests.cs index 2a8297f2b22f8..d58776c25f9d9 100644 --- a/src/Workspaces/MSBuildTest/NetCoreTests.cs +++ b/src/Workspaces/MSBuildTest/NetCoreTests.cs @@ -496,5 +496,12 @@ static void AssertSingleProjectReference(Project project, string projectRefFileP Assert.Equal(projectRefFilePath, project.Solution.GetProject(projectRefId).FilePath); } } + + [Fact] + public void BuildHostShipsDepsJsonFile() + { + var depsJsonFile = Path.ChangeExtension(BuildHostProcessManager.GetNetCoreBuildHostPath(), "deps.json"); + Assert.True(File.Exists(depsJsonFile), $"{depsJsonFile} should exist, or it won't load on some runtimes."); + } } } From 204626cf44509d1afb51982bbb36edae797c4150 Mon Sep 17 00:00:00 2001 From: Jason Malinowski Date: Fri, 12 Jan 2024 17:14:17 -0800 Subject: [PATCH 3/3] Tweaks to Workspaces.MSBuild.csproj's consumption of the build host - Change the target name so it's more aligned with otehr target names returning specific files. - Switch to TargetFrameworkIdentifier so we aren't testing for specific TFMs if we can avoid it. --- ...crosoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.csproj | 6 +++--- .../Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Workspaces/Core/MSBuild.BuildHost/Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.csproj b/src/Workspaces/Core/MSBuild.BuildHost/Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.csproj index 4d0e5b8180a5b..56259c8e5d0c2 100644 --- a/src/Workspaces/Core/MSBuild.BuildHost/Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.csproj +++ b/src/Workspaces/Core/MSBuild.BuildHost/Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.csproj @@ -56,11 +56,11 @@ - - + + $(ProjectDepsFileName) diff --git a/src/Workspaces/Core/MSBuild/Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj b/src/Workspaces/Core/MSBuild/Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj index 2d7ef0d9a1969..23eb25ab037d0 100644 --- a/src/Workspaces/Core/MSBuild/Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj +++ b/src/Workspaces/Core/MSBuild/Microsoft.CodeAnalysis.Workspaces.MSBuild.csproj @@ -117,7 +117,7 @@ - +