Skip to content

Multi-target Microsoft.NET.HostModel #114343

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

Merged
merged 2 commits into from
Apr 7, 2025

Conversation

ViktorHofer
Copy link
Member

@ViktorHofer ViktorHofer commented Apr 7, 2025

Multi-targeting allows using latest on .NETCoreApp and LKG (toolset) on .NETFramework. Should partially unblock the m-p packages dependency flow in dotnet/sdk: dotnet/sdk#48034

Multi-targeting helps to use latest on .NETCoreApp and LKG (toolset)
on .NETFramework. Should partially unblock m-p packages dependency flow in dotnet/sdk:
dotnet/sdk#48034
@Copilot Copilot AI review requested due to automatic review settings April 7, 2025 17:37
@dotnet-issue-labeler dotnet-issue-labeler bot added the area-HostModel Microsoft.NET.HostModel issues label Apr 7, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 2 out of 4 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • eng/Versions.props: Language not supported
  • src/installer/managed/Microsoft.NET.HostModel/Microsoft.NET.HostModel.csproj: Language not supported

Copy link
Member

@ericstj ericstj left a comment

Choose a reason for hiding this comment

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

LGTM

@ViktorHofer
Copy link
Member Author

ViktorHofer commented Apr 7, 2025

@elinor-fung @agocke some more context for you. I verified that all consumers of this package (just dotnet/sdk) are targeting the compatible TFMs. The package is non-shipping and just a transport from runtime to sdk - you probably know that.

The problem that I'm working around here is that this library's references needs to be in sync with sdk dependencies as it gets loaded into msbuild. Because we were targeting .NET Standard, the assembly versions didn't match (as we don't rev the assembly version on .NET Standard for System.Memory and others). By targeting runtime TFMs and downgrading the version of dependencies on .NET Framework, we should be better aligned with sdk's references.

@am11
Copy link
Member

am11 commented Apr 7, 2025

Nice! AFAICT, only four projects in dotnet org directly reference its package:

# sdk
src/Cli/dotnet/dotnet.csproj:    <TargetFramework>$(SdkTargetFramework)</TargetFramework>
src/Tasks/Microsoft.NET.Build.Tasks/Microsoft.NET.Build.Tasks.csproj:    <TargetFrameworks>$(SdkTargetFramework);net472</TargetFrameworks>
test/Microsoft.NET.ToolPack.Tests/Microsoft.NET.ToolPack.Tests.csproj:    <TargetFramework>$(SdkTargetFramework)</TargetFramework>

# runtime (TestInfraTargetFramework = NetCoreAppToolCurrent)
src/installer/tests/Microsoft.NET.HostModel.Tests/Microsoft.NET.HostModel.Tests.csproj:    <TargetFramework>$(TestInfraTargetFramework)</TargetFramework>

so one net472 and the rest are net8+.
Are there any other direct consumers of this project? (VS etc.)

@agocke
Copy link
Member

agocke commented Apr 7, 2025

I can't remember -- what's the reason we need to provide netstandard2.0 surface area for a transport package? When do we need to run on desktop FX?

@elinor-fung
Copy link
Member

The build tasks running in VS, I believe.

@ViktorHofer
Copy link
Member Author

ViktorHofer commented Apr 7, 2025

I can't remember -- what's the reason we need to provide netstandard2.0 surface area for a transport package? When do we need to run on desktop FX?

The build tasks running in VS, I believe.

We previously provided a netstandard2.0 assembly so that we didn't have to multi-target. These days, when talking to customers we actually recommend to multi-target to reduce the number of external dependencies and for efficiency.

For this library, the netstandard2.0 TFM was chosen for build authoring simplicity.

Are there any other direct consumers of this project? (VS etc.)

No. It's just dotnet/sdk.

Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

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

LGTM. I can't see any problems with multi-targeting vs netstandard

@carlossanlop
Copy link
Member

/ba-g All failures are known. The only other one was a timeout. I'll update the nit and merge right away.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-HostModel Microsoft.NET.HostModel issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants