Skip to content

.NET 8: No longer build Windows-specific assets (except on Windows) #2901

Closed

Description

@richlander

.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.

Related: dotnet/sdk#16895

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:

  • Reduce source size by 3GB.
  • Reduce build time by TBD.
  • Reduce build output size by TBD.

@MichaelSimons @mmitche @jaredpar @omajid @tmds

Activity

  1. mmitche commented on Jun 16, 2022

    @mmitche
    Member

    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.

  2. richlander commented on Jun 16, 2022

    @richlander
    MemberAuthor

    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.

  3. mmitche commented on Jun 16, 2022

    @mmitche
    Member

    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.

  4. jkotas commented on Jun 16, 2022

    @jkotas
    Member

    There are many packages in dotnet/runtime that target multitarget .NET Framework. Look for $(NetFrameworkMinimum) to find the full set.

    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.

    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.

  5. mmitche commented on Jun 16, 2022

    @mmitche
    Member

    @jkotas Is there a reason to keep this targeting around long term?

  6. jkotas commented on Jun 16, 2022

    @jkotas
    Member

    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.

  7. richlander commented on Jun 16, 2022

    @richlander
    MemberAuthor

    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?

  8. mmitche commented on Jun 16, 2022

    @mmitche
    Member

    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.

  9. richlander commented on Jun 16, 2022

    @richlander
    MemberAuthor

    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?

  10. mmitche commented on Jun 16, 2022

    @mmitche
    Member

    They're already on NuGet. Just need restore them (the SDK does this automatically I think).

  11. richlander commented on Jun 16, 2022

    @richlander
    MemberAuthor

    Right.

  12. changed the title [-].NET 8: No longer multi-target for net4*[/-] [+].NET 8: No longer multi-target for net4* (except on Windows)[/+] on Jun 16, 2022
  13. terrajobst commented on Jun 16, 2022

    @terrajobst

    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.

  14. 6 remaining items

  15. added
    area-product-experience
    and removed on Jun 23, 2022
  16. ericstj commented on Jun 23, 2022

    @ericstj
    Member

    @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.

  17. mmitche commented on Jun 27, 2022

    @mmitche
    Member

    @ericstj Alright, sounds good. Thanks for the clarification.

  18. 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
  19. richlander commented on Jun 27, 2022

    @richlander
    MemberAuthor

    I changed the issue title to make it more general and implementation-agnostic.

  20. tmds commented on Jul 8, 2022

    @tmds
    Member

    +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.

  21. MichaelSimons commented on Jul 8, 2022

    @MichaelSimons
    Member

    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.

  22. tmds commented on Jul 8, 2022

    @tmds
    Member

    FYI, This improvement was already made in .NET 6.0. The ref packages are getting built as part of the product.

    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 ILsrc for a tarball generated from main:

    24M	microsoft.aspnetcore.app.ref/3.0.1
    30M	microsoft.aspnetcore.app.ref/3.1.10
    43M	microsoft.aspnetcore.app.ref/5.0.0
    41M	microsoft.netcore.app/2.0.0
    41M	microsoft.netcore.app/2.1.0
    47M	microsoft.netcore.app.ref/3.0.0
    47M	microsoft.netcore.app.ref/3.1.0
    57M	microsoft.netcore.app.ref/5.0.0
    8.0K	microsoft.netframework.referenceassemblies/1.0.2
    52M	microsoft.netframework.referenceassemblies.net20/1.0.2
    517M	microsoft.netframework.referenceassemblies.net40/1.0.2
    268M	microsoft.netframework.referenceassemblies.net45/1.0.2
    269M	microsoft.netframework.referenceassemblies.net451/1.0.2
    268M	microsoft.netframework.referenceassemblies.net452/1.0.2
    269M	microsoft.netframework.referenceassemblies.net46/1.0.2
    272M	microsoft.netframework.referenceassemblies.net461/1.0.2
    270M	microsoft.netframework.referenceassemblies.net462/1.0.2
    273M	microsoft.netframework.referenceassemblies.net47/1.0.2
    275M	microsoft.netframework.referenceassemblies.net472/1.0.2
    275M	microsoft.netframework.referenceassemblies.net48/1.0.2
    24K	netstandard.library/1.6.1
    33M	netstandard.library/2.0.0
    33M	netstandard.library/2.0.3
    16M	netstandard.library.netframework/2.0.1-servicing-26011-01
    35M	netstandard.library.ref/2.1.0
    
  23. MichaelSimons commented on Jul 8, 2022

    @MichaelSimons
    Member

    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.

  24. MichaelSimons commented on Jun 8, 2023

    @MichaelSimons
    Member

    This work was completed in #3014.

  25. moved this from Needs Review to Done in .NET Source Buildon Jun 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-product-experience

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions