Skip to content

Microsoft.NET.ILLink.Tasks in .NET 8 does not target .NET 8 #82241

Closed

Description

@rolfbjarne

Description

The Microsoft.NET.ILLink.Tasks NuGet in .NET 8 preview 1 does not target .NET 8, causing problems for custom linker steps when they are built with .NET 8.

Reproduction Steps

Follow the instructions here: https://gist.github.com/jonathanpeppers/99961b4639823206c2537c03c856b097, except:

  1. Install a later version of the .NET 8 preview 1
  2. Make sure .NET 7 is installed too.

Create a new maui project and try to build it:

$ dotnet new maui
$ dotnet build -f net8.0-ios

Expected behavior

Successful build.

Actual behavior

Build failure:

Fatal error in IL Linker

  Unhandled exception. System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.

   ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Collections, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.   File name: 'System.Collections, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

     at MonoTouch.Tuner.CoreTypeMapStep..ctor()

     at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)

     --- End of inner exception stack trace ---

     at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)

     at Mono.Linker.Driver.AddCustomStep(Pipeline pipeline, String arg)

     at Mono.Linker.Driver.SetupContext(ILogger customLogger)

     at Mono.Linker.Driver.Run(ILogger customLogger)

     at Mono.Linker.Driver.Main(String[] args)

/Users/dmo/.nuget/packages/microsoft.net.illink.tasks/8.0.100-1.23067.1/build/Microsoft.NET.ILLink.targets(133,5): error MSB6006: "dotnet" exited with code 134. [/Users/dmo/work/CrazyEights/CrazyEights.csproj::TargetFramework=net8.0-ios]

/Users/dmo/.nuget/packages/microsoft.net.illink.tasks/8.0.100-1.23067.1/build/Microsoft.NET.ILLink.targets(86,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false. [/Users/dmo/work/CrazyEights/CrazyEights.csproj::TargetFramework=net8.0-ios]

Regression?

Yes

Known Workarounds

Remove .NET 7.

Configuration

.NET 8.0.100-preview.1.23115.2

Other information

It's because this NuGet: https://dev.azure.com/dnceng/public/_artifacts/feed/dotnet8/NuGet/Microsoft.NET.ILLink.Tasks/versions/8.0.100-1.23067.1 is built for .NET 7:

$ unzip -l /Users/rolf/Downloads/microsoft.net.illink.tasks.8.0.100-1.23067.1.nupkg
Archive:  /Users/rolf/Downloads/microsoft.net.illink.tasks.8.0.100-1.23067.1.nupkg
  Length      Date    Time    Name
---------  ---------- -----   ----
      520  01-17-2023 18:35   _rels/.rels
      977  01-17-2023 18:35   Microsoft.NET.ILLink.Tasks.nuspec
    39872  01-17-2023 18:35   tools/net472/ILLink.Tasks.dll
   421328  01-17-2023 18:34   tools/net472/Mono.Cecil.dll
    20856  02-19-2020 10:05   tools/net472/System.Buffers.dll
   189312  10-19-2020 18:37   tools/net472/System.Collections.Immutable.dll
   141184  02-19-2020 10:05   tools/net472/System.Memory.dll
   115856  05-15-2018 13:29   tools/net472/System.Numerics.Vectors.dll
   462728  10-19-2020 18:45   tools/net472/System.Reflection.Metadata.dll
    16768  10-19-2020 18:46   tools/net472/System.Runtime.CompilerServices.Unsafe.dll
   721296  01-17-2023 18:35   tools/net7.0/illink.dll
    40376  01-17-2023 18:35   tools/net7.0/ILLink.Tasks.dll
   421328  01-17-2023 18:34   tools/net7.0/Mono.Cecil.dll
   103888  01-17-2023 18:35   tools/net7.0/Mono.Cecil.Pdb.dll
     6822  01-17-2023 18:35   tools/net7.0/illink.deps.json
      324  01-17-2023 18:35   tools/net7.0/illink.runtimeconfig.json
    24890  01-17-2023 18:35   tools/net7.0/ILLink.Tasks.deps.json
      783  01-17-2023 18:33   Sdk/Sdk.props
     1451  01-17-2023 18:33   build/Microsoft.NET.ILLink.Tasks.props
    21256  01-17-2023 18:33   build/Microsoft.NET.ILLink.targets
    10806  01-17-2023 18:33   build/6.0_suppressions.xml
     7006  12-30-2022 18:15   Icon.png
      787  01-17-2023 18:35   [Content_Types].xml
      664  01-17-2023 18:35   package/services/metadata/core-properties/c7cfde231f344fc9b00bdaf0b59aea91.psmdcp
    11403  01-17-2023 10:38   .signature.p7s
---------                     -------
  2782481                     25 files

and our custom linker steps are built using .NET 8, thus things go wrong when the .NET 7 version of illink.dll (running on .NET 7) tries to load the custom linker steps built with .NET 8 (and this is also why having .NET 7 installed is required to reproduce the problem: if .NET 7 is not installed, illink.dll will be executed with .NET 8, and everything works).

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Feb 16, 2023
  2. rolfbjarne commented on Feb 16, 2023

    @rolfbjarne
    MemberAuthor
  3. marek-safar commented on Feb 16, 2023

    @marek-safar
    Contributor

    @rolfbjarne does it block P1 for you?

  4. added
    area-Tools-ILLink.NET linker development as well as trimming analyzers
    and removed
    untriagedNew issue has not been triaged by the area owner
    on Feb 16, 2023
  5. added this to the 8.0.0 milestone on Feb 16, 2023
  6. rolfbjarne commented on Feb 16, 2023

    @rolfbjarne
    MemberAuthor

    @marek-safar we might have a workaround: dotnet/macios#17560

  7. sbomer commented on Feb 16, 2023

    @sbomer
    Member

    This should also be fixed when updating to an SDK with dotnet/installer#15484 (although I understand that may be blocked as in dotnet/macios#17518). The 8.0.100-* packages built from dotnet/linker weren't updated to target net8, while the 8.0.0-preview* ones built from dotnet/runtime do target net8.

  8. agocke commented on Feb 16, 2023

    @agocke
    Member

    That fix wasn't in Preview 1, so you'll have to work around this for Preview 1.

  9. 2 remaining items

  10. EgorBo commented on Feb 21, 2023

    @EgorBo
    Member

    um.. after clearing my local nuget cache via dotnet nuget locals all --clear I can't even build a simple NativeAOT hello world with public .NET 8.0 Preview1:

    mkdir eee
    cd eee
    dotnet new console
    dotnet publish -c Release -r win-x64 /p:PublishAot=true /p:StripSymbols=true
    
    MSBuild version 17.6.0-preview-23108-10+51df47643 for .NET
      Determining projects to restore...
    C:\prj\eee\eee.csproj : error NU1101: Unable to find package Microsoft.NET.ILLink.Tasks. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages, nuget.org
      Failed to restore C:\prj\eee\eee.csproj (in 5.77 sec).
    

    cc @agocke @MichalStrehovsky

  11. agocke commented on Feb 21, 2023

    @agocke
    Member

    @EgorBo Did you add the .NET 8 package source as specified in https://github.com/dotnet/installer#installers-and-binaries?

  12. EgorBo commented on Feb 21, 2023

    @EgorBo
    Member

    @EgorBo Did you add the .NET 8 package source as specified in https://github.com/dotnet/installer#installers-and-binaries?

    I thought those are only for daily bits, public previews used to work fine without it, didn't they?

  13. agocke commented on Feb 21, 2023

    @agocke
    Member

    Oh, nvm, I see Preview 1 was just officially released. I think it takes a bit for packages to flow to public servers. Last time I checked it took a few hours at least.

  14. agocke commented on Feb 21, 2023

    @agocke
    Member

    That said, not a bad idea to confirm that the packages are set for release. @mmitche any way to verify that the runtime packs are going to published to NuGet?

  15. JeepNL commented on Feb 21, 2023

    @JeepNL

    I'm getting this error in Microsoft Visual Studio Community 2022 (64-bit) - Version 17.6.0 Preview 1.0 with a Blazor WASM project. 7.x is installed too.

    Severity Code Description Project File Line Suppression State
    Error NU1101 Unable to find package Microsoft.NET.ILLink.Tasks. No packages exist with this id in source(s): C:\Program Files\dotnet\library-packs, Microsoft Visual Studio Offline Packages, nuget.org Client.Tusk C:\X\Repos\Tusk\ClientTusk\Client.Tusk.csproj 1

    .csproj

      <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.0-preview.1.23112.2" />
        <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.0-preview.1.23112.2" PrivateAssets="all" />
      </ItemGroup>
    

    [UPDATE]

    Visual Studio Nuget Screenshot
    Screenshot 2023-02-21 230817

  16. sbomer commented on Feb 21, 2023

    @sbomer
    Member

    I think this is specific to the linker packages, not all of the runtime packs. I see for example that the preview1 netcoreapp package was published: https://www.nuget.org/packages/Microsoft.NETCore.App.Runtime.linux-x64/8.0.0-preview.1.23110.8#versions-body-tab. We need the following versions of Microsoft.NET.ILLink.Tasks to be published:

    1. latest 7.0 package (currently 7.0.100-1.23062.2)
    2. last 8.0 package taken from dotnet/linker (8.0.100-1.23067.1)
    3. future 7.0 packages from dotnet/linker
    4. future 8.0 packages from dotnet/runtime

    I suspect that 1-3 are not getting published because they are built out of the dotnet/linker repo (but I hope 4 will "just work" since that should be no different than the other runtime packs).

  17. agocke commented on Feb 21, 2023

    @agocke
    Member

    It looks like the package was missing for arbitrary reasons -- we're uploading it now.

  18. agocke commented on Feb 21, 2023

    @agocke
    Member

    Package should be uploaded now, this should hopefully be fixed.

  19. KeterSCP commented on Feb 21, 2023

    @KeterSCP

    I can confirm that error is gone and build/publish works fine now

  20. JeepNL commented on Feb 21, 2023

    @JeepNL

    Yep, it works with Visual Studio 17.6.0 Preview 1.0 and my Blazor WASM project too.

  21. agocke commented on Feb 22, 2023

    @agocke
    Member

    Closing as this should be resolved in main

  22. ghost locked as resolved and limited conversation to collaborators on Mar 25, 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-Tools-ILLink.NET linker development as well as trimming analyzers

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions