Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch the BuildHost to build with net6.0 again #71881

Conversation

jasonmalinowski
Copy link
Member

@jasonmalinowski jasonmalinowski commented Jan 30, 2024

When we launch the BuildHost we generally use the dotnet.exe on the path, which the assumption that's the one the user is using for their development and that has the right SDKs installed. This means we can run into some fun version issues with VS Code though, where we target the language server on net7.0 (of this writing); in the case that the user has only a 6.0 SDK + runtime installed globally, we'll download a 7.0 runtime, but that's only used for the language server process. The BuildHost will still run with the regular dotnet.exe which needs to support 6.0 runtimes + SDKs.

This PR downgrades us to use net6.0 for just the build host. The core change there is trivial but it did result in a few other changes:

  1. The Microsoft.Build packages only support net7.0 or higher, so we switch back to the version that we're using for source build which are old enough. Since we only use them as reference assemblies, it doesn't really matter what we pick.
  2. 6.0 builds are then missing some attributes we have on higher versions, so we need to start declaring them again.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jan 30, 2024
dibarbet
dibarbet previously approved these changes Jan 30, 2024
Copy link
Member

@dibarbet dibarbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm excited to see how this will break source build

@@ -9,6 +9,7 @@ The roslyn repository produces components for a number of different products tha
- Source build: requires us to ship `$(NetCurrent)` and `$(NetPrevious)` in workspaces and below (presently `net9.0` and `net8.0` respectively)
- Visual Studio: requires us to ship `net472` for base IDE components and `$(NetVisualStudio)` (presently `net8.0`) for private runtime components.
- Visual Studio Code: expects us to ship against the same runtime as DevKit (presently `net7.0`) to avoid two runtime downloads.
- MSBuildWorkspace: requires to ship a process that must be usable on the lowest supported SDK (presently `net6.0`)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess the expiration date for this Nov 12th 2024?
https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#lifecycle

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, depends on whether we support officially unsupported things. Which is often case in the tooling world...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reminds me that I need to pin an O# announcement about dropping .NET 6/7 support in November.

@jasonmalinowski jasonmalinowski force-pushed the switch-back-to-net6.0-for-buildhost branch 2 times, most recently from 03d0fbc to daaadfc Compare January 31, 2024 00:12
@jasonmalinowski jasonmalinowski self-assigned this Jan 31, 2024
@jasonmalinowski jasonmalinowski force-pushed the switch-back-to-net6.0-for-buildhost branch from daaadfc to 6fe03b2 Compare January 31, 2024 00:30
@jasonmalinowski jasonmalinowski force-pushed the switch-back-to-net6.0-for-buildhost branch from 6fe03b2 to 0bba456 Compare January 31, 2024 01:22
@jasonmalinowski jasonmalinowski marked this pull request as ready for review January 31, 2024 01:22
@jasonmalinowski jasonmalinowski requested review from a team as code owners January 31, 2024 01:22
Comment on lines +109 to +111
#if NET472 || NET6_0 // If we're compiling against net472 or net6.0, we get our MemberNotNull from the workspaces assembly. It has it in the net6.0 case since we're consuming the netstandard2.0 version of Workspaces.
[workspaces::System.Diagnostics.CodeAnalysis.MemberNotNull(nameof(_buildManager))]
#else // If we're compiling against net7.0 or higher, then we're getting it staright from the framework.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I absolutely hate this. If I don't qualify this, then we end up with conflicts since this exists in both the Workspaces DLL (visible via IVT) and also the System.Runtime reference that was getting pulled in some way. I wish there was a way for me to say just-pick-one::MemberNotNull() and the compiler picks one arbitrarily. @jaredpar told me that if I mention this to @333fred and @chsienki that this might make them sad enough to want to address this.

Longer term, the plan is to remove the reference on the Workspaces DLL entirely, since it's mostly just being used for attributes like this, or for our Contract type. Removing the reference entirely would slim down our deploy size and also just generally remove tangles like this. Getting rid of the compiler layer reference too ensures that this is just a simple isolated process with absolutely no references to get messed up with something else.

When we launch the BuildHost we generally use the dotnet.exe on the
path, which the assumption that's the one the user is using for their
development and that has the right SDKs installed. This means we can
run into some fun version issues with VS Code though, where we target
the language server on net7.0 (of this writing); in the case that
the user has only a 6.0 SDK + runtime installed globally, we'll download
a 7.0 runtime, but that's only used for the language server process.
The BuildHost will still run with the regular dotnet.exe which needs
to support 6.0 runtimes + SDKs.

This PR downgrades us to use net6.0 for just the build host. The core
change there is trivial but it did result in a few other changes:

1. The Microsoft.Build packages only support net7.0 or higher, so we
   switch back to the version that we're using for source build
   which are old enough. Since we only use them as reference assemblies,
   it doesn't really matter what we pick.
2. 6.0 builds are then missing some attributes we have on higher
   versions, so we need to start declaring them again.
@jasonmalinowski jasonmalinowski dismissed dibarbet’s stale review January 31, 2024 18:39

A bunch of changes were made.

@jasonmalinowski jasonmalinowski force-pushed the switch-back-to-net6.0-for-buildhost branch from 0bba456 to ad1135e Compare January 31, 2024 18:41
Comment on lines -100 to -103
<_NetFrameworkBuildHostProjectReference Include="..\..\..\Workspaces\Core\MSBuild.BuildHost\Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost.csproj">
<TargetFramework>$(NetVSCode)</TargetFramework>
<ContentFolderName>BuildHost-netcore</ContentFolderName>
</_NetFrameworkBuildHostProjectReference>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only difference between this and the next one was the TFM, but now that we have a single variable conditioned elsewhere, we can just remove it from the condition block.

@@ -4,7 +4,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<RootNamespace>Microsoft.CodeAnalysis</RootNamespace>
<TargetFrameworks>$(NetRoslynSourceBuild);net472</TargetFrameworks>
<TargetFrameworks>$(NetRoslynBuildHostNetCoreVersion);net472</TargetFrameworks>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This means though that the .NET core build host will be a net6.0 binary which pulls in all other Roslyn components at netstandard2.0. Want to make sure that is understood here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is understood and fine since we only use a very tiny bit of those other assemblies. #70945 tracks removing the ProjectReferences entirely since we end up using only a tiny bit of code but end up deploying a lot of binaries in the process. I think severing the references too will also help with maintenance here simply because it means the cross-TFM adventures go away and this is a very isolated project.

@dotnet dotnet deleted a comment from azure-pipelines bot Feb 2, 2024
@jasonmalinowski jasonmalinowski merged commit b14dc4d into dotnet:main Feb 3, 2024
28 of 31 checks passed
@ghost ghost added this to the Next milestone Feb 3, 2024
@jasonmalinowski jasonmalinowski deleted the switch-back-to-net6.0-for-buildhost branch February 12, 2024 23:27
@jjonescz jjonescz modified the milestones: Next, 17.10 P2 Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants