dotnet / dotnet/linker

error IL1012: IL Linker has encountered an unexpected error.

Open
#2,361 9 comments 0 reactions 0 assignees View on GitHub
needs more info
Dominant language
C#
Stars
392
Forks
128
Avg merge
2d 10h
Merged PRs (30d)
2

Description

I am investigating a CI build failure of a project that I am hardly familiar with. This project built just fine a couple of days ago and without any changes to the code base, is failing reliably today.

From what I can tell, this is the relevant part of the build log relating to the error:
```
ILLink : error IL1012: IL Linker has encountered an unexpected error. Please report the issue at https://github.com/mono/linker/issues [C:\gitlab-runner\builds\qFSfUy_u\0\fairmanager-frontend\2081_fairmanager_eventplatform\Fairmanager.Admin\Fairmanager.Admin.csproj]
Fatal error in IL Linker
Unhandled exception. System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\WINDOWS\system32\config\systemprofile\.nuget\packages\microsoft.netcore.app.runtime.browser-wasm\5.0.12\runtimes\browser-wasm\lib\net5.0\System.Net.Primitives.dll'.
at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, Boolean useAsync)
at Mono.Linker.DirectoryAssemblyResolver.GetAssembly(String file, ReaderParameters parameters)
at Mono.Linker.AssemblyResolver.ResolveFromReferences(AssemblyNameReference name, Collection`1 references, ReaderParameters parameters)
at Mono.Linker.AssemblyResolver.Resolve(AssemblyNameReference name, ReaderParameters parameters)
at Mono.Linker.DirectoryAssemblyResolver.Resolve(AssemblyNameReference name)
at Mono.Cecil.MetadataResolver.Resolve(TypeReference type)
at Mono.Cecil.ModuleDefinition.Resolve(TypeReference type)
at Mono.Cecil.ExportedType.Resolve()
at Mono.Linker.Steps.ResolveFromAssemblyStep.ProcessLibrary(LinkContext context, AssemblyDefinition assembly, RootVisibility rootVisibility)
at Mono.Linker.Steps.ResolveFromAssemblyStep.ProcessLibrary(AssemblyDefinition assembly)
at Mono.Linker.Steps.ResolveFromAssemblyStep.Process()
at Mono.Linker.Steps.BaseStep.Process(LinkContext context)
at Mono.Linker.Pipeline.ProcessStep(LinkContext context, IStep step)
at Mono.Linker.Pipeline.Process(LinkContext context)
at Mono.Linker.Driver.Run(ILogger customLogger)
at Mono.Linker.Driver.Main(String[] args)
Build continuing because "ContinueOnError" on the task "ILLink" is set to "ErrorAndContinue".
ILLink:
Optimizing assemblies for size, which may change the behavior of the app. Be sure to test after publishing. See: https://aka.ms/dotnet-illink
C:\Program Files\dotnet\sdk\5.0.403\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.ILLink.targets(41,5): error NETSDK1144: Optimizing assemblies for size failed. Optimization can be disabled by setting the PublishTrimmed property to false. [C:\gitlab-runner\builds\qFSfUy_u\0\fairmanager-frontend\2081_fairmanager_eventplatform\Fairmanager.Admin\Fairmanager.Admin.csproj]
Done Building Project "C:\gitlab-runner\builds\qFSfUy_u\0\fairmanager-frontend\2081_fairmanager_eventplatform\Fairmanager.Admin\Fairmanager.Admin.csproj" (Publish target(s)) -- FAILED.
```
As the error output suggests, setting `PublishTrimmed` to `false` allows the build to pass again.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.