Skip to content

NativeAOT publish should respect updating FrameworkReference RuntimeFrameworkVersion #81382

@eerhardt

Description

@eerhardt

In Microsoft.Crank and the ASP.NET Benchmarks, we specify a specific .NET runtime version to use using the following code:

https://github.com/dotnet/crank/blob/5e7a8b90f56129d8c23dfa4693bd41deeddc9fc3/src/Microsoft.Crank.Agent/Startup.cs#L3551-L3584

                    if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
                    {
                        project.Root.Add(
                            new XElement("ItemGroup",
                                new XElement("FrameworkReference",
                                    new XAttribute("Update", "Microsoft.AspNetCore.App"),
                                    new XAttribute("RuntimeFrameworkVersion", "$(MicrosoftAspNetCoreAppPackageVersion)")
                                    ),
                                new XElement("FrameworkReference",
                                    new XAttribute("Update", "Microsoft.NETCore.App"),
                                    new XAttribute("RuntimeFrameworkVersion", "$(MicrosoftNETCoreAppPackageVersion)")
                                )
                            )
                        );
                    }
                    else
                    {
                        project.Root.Add(
                            new XElement("ItemGroup",
                                new XElement("FrameworkReference",
                                    new XAttribute("Update", "Microsoft.AspNetCore.App"),
                                    new XAttribute("RuntimeFrameworkVersion", "$(MicrosoftAspNetCoreAppPackageVersion)")
                                    ),
                                new XElement("FrameworkReference",
                                    new XAttribute("Update", "Microsoft.NETCore.App"),
                                    new XAttribute("RuntimeFrameworkVersion", "$(MicrosoftNETCoreAppPackageVersion)")
                                    ),
                                new XElement("FrameworkReference",
                                    new XAttribute("Update", "Microsoft.WindowsDesktop.App"),
                                    new XAttribute("RuntimeFrameworkVersion", "$(MicrosoftWindowsDesktopAppPackageVersion)")
                                    )
                            )
                        );
                    }

For "normal" CoreCLR apps, this is all that is needed to specify which version of the runtime to use.

However, this doesn't work with -p:PublishAot=true. If I add:

  <ItemGroup>
    <FrameworkReference Update="Microsoft.NETCore.App"
                        RuntimeFrameworkVersion="8.0.0-alpha.1.23080.1" />
  </ItemGroup>

To my .csproj, and then inspect the ilc.rsp file that says which version of the runtime is being used, I see:

-r:C:\Users\eerhardt\.nuget\packages\runtime.win-x64.microsoft.dotnet.ilcompiler\8.0.0-alpha.1.23074.4\sdk\System.Private.CoreLib.dll

The PublishAot tooling should respect updating the FrameworkReference, just like other .NET apps do.

Because of this, we don't pick up the latest runtime changes in the ASP.NET AOT benchmarks until the runtime has flown all the way to dotnet/installer. We want to support the same workflow as the rest of the benchmarks, and pick up the latest runtime version as the official build is built.

cc @agocke @MichalStrehovsky @vitek-karas @sebastienros

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions