You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
.NET 8: No longer build Windows-specific assets (except on Windows) #2901
.NET has various construction challenges. One of them is that various product assets are multi-targeted for net4* targets, which we build, taking both time and space. The product would be faster to build and smaller if we did not build those targets. We should find a way to achieve that.
These assets are mostly (or entirely) unvaluable and unused. Also, today source-build targets Linux, where net4* is the least likely to be valuable.
The .NET SDK enables building net4* assets. It adds a PackageReference to Microsoft.NETFramework.ReferenceAssemblies. We can continue to offer that. It is largely unrelated to this topic.
It would be useful to do three things:
Determine the cost of these assets, in built time and/or output size.
Validate the premise that these assets are unused/unvaluable.
Can we just target net8 and netstandard*. What scenarios require targeting other TFMs?
The initial findings is that removing .NET Framework targeting would:
We'll need to figure out where the net4* usage is coming from. I took a quick look yesterday at runtime and aspnetcore, and here is what I saw offhand:
Infrastructure - Some tools and tasks that use the desktop runtime. Some (most) of these are probably movable to core. Obviously any of these tools wouldn't work on Linux or Mac anyway. My recommendation would be to triage them and try to move all infra/tooling to core.
Tests - There were a bunch of test projects that multi-targeted. Those could go away I think
Product - I found at least one place in aspnetcore (src/SiteExtensions/Runtime/Microsoft.AspNetCore.Runtime.SiteExtension.pkgproj) that targets 462.
I am all for a full move to core.
Reacted by Omair Majid, Michael Simons and Nirmal Guru
We can also make rules per platform. Basically say: Windows can use desktop targeting packs as a pre-built input, but it's not allowed on Linux. So when building for Linux, we don't build those RIDs.
It's likely we will find cases where we need to build something for desktop (e..g tooling that can't be ported). We shouldn't penalize all platforms though.
For as long as we want to keep supporting .NET Framework with the OOB dotnet/runtime packages. It is a complex topic. For example, we have some evidence that .NET Framework support allows people to modernize faster since they do not have to move from .NET Framework to .NET Core at once.
For as long as we want to keep supporting .NET Framework with the OOB dotnet/runtime packages.
That's goodness.
Can those packages be built from dotnet/runtime and not souce-build, at all?
We shouldn't do that. That keeps the runtime build around, as well as any dependency flow and build that consumes these packages. In other words, you're basically in the same situation as today, perhaps with more complexity.
I think the right call here is to remove the framework packages from the source build reference packages, and conditionalize the build so that those TFMs are not built when targeting platforms that do not allow an online restore (or need them). Basically anything but Windows.
There really cannot be independent repo official builds for anything but some isolated leaf components like the tooling.
Generally speaking, we should tie multi-targeting for net4x to whether or not we offer netstandard2.0. That's because .NET Framework 4.6.1 is considered implementing .NET Standard 2.0 but it only rally works starting with .NET Framework 4.7.2.
Said differently: If you target netstandard2.0, you should also target net461.
Edit: Looks like we're talking about different things here. This is about building the .NET platform from source, which today only happens on Linux, for Linux, specifically Red Hat. I'd agree that in that context building any Windows assets is a waste of resources, which includes net4x.
@mmitche - what I'm saying is not disagreeing with you at all. I'm saying that instead of removing .NETFramework from the packages, you just need to think of those packages as a different vertical. Packages are immutable and making them behave differently for source build just to facilitate codeflow and never ship them is a pretty big hack. Instead we should be thinking about those packages as produced by a vertical that's capable of producing their content. For source build we avoid depending on packages that need to have more content than is necessary for a vertical product build. In this way we'll actually naturally land in a place where we clean up the vertical source builds to produce just what we need.
changed the title [-].NET 8: No longer multi-target for net4* (except on Windows)[/-][+].NET 8: No longer build Windows-specific assets (except on Windows)[/+]on Jun 27, 2022
+1000 for eliminating the net4* targets and getting rid of 3GB of IL sources.
Note that previously we needed these targets to build assemblies used by mono-based OmniSharp.
OmniSharp has switched to .NET (Core), so we don't need them anymore.
Ideally, a source-build of .NET X.0 should require netX.0 as a target framework only.
And, the ref packages (for .NET Core, and ASP.NET Core) for that target framework should be buildable from the runtime/aspnetcore repo sources and not require separate IL dumps.
And, the ref packages (for .NET Core, and ASP.NET Core) for that target framework should be buildable from the runtime/aspnetcore repo sources and not require separate IL dumps.
@tmds - FYI, This improvement was already made in .NET 6.0. The ref packages are getting built as part of the product.
Unfortunately only the .NET current ref packages are produced by the current build. That aside, I think we are on the same page as far as where we need to get to.
Activity
mmitche commentedon Jun 16, 2022
We'll need to figure out where the net4* usage is coming from. I took a quick look yesterday at runtime and aspnetcore, and here is what I saw offhand:
I am all for a full move to core.
richlander commentedon Jun 16, 2022
We either need to "full move to core" or have a new feature that ignores certain families of targets. Possibly we'll need a bit of both.
mmitche commentedon Jun 16, 2022
We can also make rules per platform. Basically say: Windows can use desktop targeting packs as a pre-built input, but it's not allowed on Linux. So when building for Linux, we don't build those RIDs.
It's likely we will find cases where we need to build something for desktop (e..g tooling that can't be ported). We shouldn't penalize all platforms though.
jkotas commentedon Jun 16, 2022
There are many packages in dotnet/runtime that target multitarget .NET Framework. Look for
$(NetFrameworkMinimum)to find the full set.Yes, that's definitely an option. In other words, we would say that the Microsoft-built nuget packages cannot be built via offline source build.
mmitche commentedon Jun 16, 2022
@jkotas Is there a reason to keep this targeting around long term?
jkotas commentedon Jun 16, 2022
For as long as we want to keep supporting .NET Framework with the OOB dotnet/runtime packages. It is a complex topic. For example, we have some evidence that .NET Framework support allows people to modernize faster since they do not have to move from .NET Framework to .NET Core at once.
richlander commentedon Jun 16, 2022
That's goodness.
Can those packages be built from dotnet/runtime and not souce-build, at all?
mmitche commentedon Jun 16, 2022
We shouldn't do that. That keeps the runtime build around, as well as any dependency flow and build that consumes these packages. In other words, you're basically in the same situation as today, perhaps with more complexity.
I think the right call here is to remove the framework packages from the source build reference packages, and conditionalize the build so that those TFMs are not built when targeting platforms that do not allow an online restore (or need them). Basically anything but Windows.
There really cannot be independent repo official builds for anything but some isolated leaf components like the tooling.
richlander commentedon Jun 16, 2022
OK. Makes sense.
Does generating the net[old] targeting packs need to be done from this repo? That can surely be a foreign pre-built. Right?
mmitche commentedon Jun 16, 2022
They're already on NuGet. Just need restore them (the SDK does this automatically I think).
richlander commentedon Jun 16, 2022
Right.
[-].NET 8: No longer multi-target for net4*[/-][+].NET 8: No longer multi-target for net4* (except on Windows)[/+]terrajobst commentedon Jun 16, 2022
Generally speaking, we should tie multi-targeting fornet4xto whether or not we offernetstandard2.0. That's because .NET Framework 4.6.1 is considered implementing .NET Standard 2.0 but it only rally works starting with .NET Framework 4.7.2.Said differently: If you targetnetstandard2.0, you should also targetnet461.Edit: Looks like we're talking about different things here. This is about building the .NET platform from source, which today only happens on Linux, for Linux, specifically Red Hat. I'd agree that in that context building any Windows assets is a waste of resources, which includes
net4x.6 remaining items
ericstj commentedon Jun 23, 2022
@mmitche - what I'm saying is not disagreeing with you at all. I'm saying that instead of removing .NETFramework from the packages, you just need to think of those packages as a different vertical. Packages are immutable and making them behave differently for source build just to facilitate codeflow and never ship them is a pretty big hack. Instead we should be thinking about those packages as produced by a vertical that's capable of producing their content. For source build we avoid depending on packages that need to have more content than is necessary for a vertical product build. In this way we'll actually naturally land in a place where we clean up the vertical source builds to produce just what we need.
mmitche commentedon Jun 27, 2022
@ericstj Alright, sounds good. Thanks for the clarification.
[-].NET 8: No longer multi-target for net4* (except on Windows)[/-][+].NET 8: No longer build Windows-specific assets (except on Windows)[/+]richlander commentedon Jun 27, 2022
I changed the issue title to make it more general and implementation-agnostic.
tmds commentedon Jul 8, 2022
+1000 for eliminating the
net4*targets and getting rid of 3GB of IL sources.Note that previously we needed these targets to build assemblies used by mono-based OmniSharp.
OmniSharp has switched to .NET (Core), so we don't need them anymore.
Ideally, a source-build of .NET X.0 should require
netX.0as a target framework only.And, the ref packages (for .NET Core, and ASP.NET Core) for that target framework should be buildable from the runtime/aspnetcore repo sources and not require separate IL dumps.
MichaelSimons commentedon Jul 8, 2022
@tmds - FYI, This improvement was already made in .NET 6.0. The ref packages are getting built as part of the product.
tmds commentedon Jul 8, 2022
When we can, we should remove the IL sources.
Besides not targeting
net4*we should also not target older versions of .NET Core.This is what we have in
ILsrcfor a tarball generated frommain:MichaelSimons commentedon Jul 8, 2022
Unfortunately only the .NET current ref packages are produced by the current build. That aside, I think we are on the same page as far as where we need to get to.
MichaelSimons commentedon Jun 8, 2023
This work was completed in #3014.