Repository navigation
Microsoft.NET.ILLink.Tasks in .NET 8 does not target .NET 8 #82241
Description
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:
- Install a later version of the .NET 8 preview 1
- 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-iosExpected 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 filesand 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
rolfbjarne commentedon Feb 16, 2023
CC @marek-safar @sbomer
[release/8.0.1xx-preview1] [dotnet-linker] Make this a .NET 7 app to …
marek-safar commentedon Feb 16, 2023
@rolfbjarne does it block P1 for you?
rolfbjarne commentedon Feb 16, 2023
@marek-safar we might have a workaround: dotnet/macios#17560
sbomer commentedon Feb 16, 2023
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.
agocke commentedon Feb 16, 2023
That fix wasn't in Preview 1, so you'll have to work around this for Preview 1.
[Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily
2 remaining items
[Microsoft.Android.Sdk.ILLink] target `net7.0` temporarily (#7803)
EgorBo commentedon Feb 21, 2023
um.. after clearing my local nuget cache via
dotnet nuget locals all --clearI can't even build a simple NativeAOT hello world with public .NET 8.0 Preview1:cc @agocke @MichalStrehovsky
agocke commentedon Feb 21, 2023
@EgorBo Did you add the .NET 8 package source as specified in https://github.com/dotnet/installer#installers-and-binaries?
EgorBo commentedon Feb 21, 2023
I thought those are only for daily bits, public previews used to work fine without it, didn't they?
agocke commentedon Feb 21, 2023
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.
agocke commentedon Feb 21, 2023
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?
JeepNL commentedon Feb 21, 2023
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
[UPDATE]
Visual Studio Nuget Screenshot

sbomer commentedon Feb 21, 2023
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:
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).
agocke commentedon Feb 21, 2023
It looks like the package was missing for arbitrary reasons -- we're uploading it now.
agocke commentedon Feb 21, 2023
Package should be uploaded now, this should hopefully be fixed.
KeterSCP commentedon Feb 21, 2023
I can confirm that error is gone and build/publish works fine now
JeepNL commentedon Feb 21, 2023
Yep, it works with Visual Studio 17.6.0 Preview 1.0 and my Blazor WASM project too.
agocke commentedon Feb 22, 2023
Closing as this should be resolved in
main