Skip to content
This repository was archived by the owner on Sep 25, 2026. It is now read-only.
This repository was archived by the owner on Sep 25, 2026. It is now read-only.

Improve error experience for invalid descriptor files #653

Closed

Description

@rynowak

Adding something invalid in a linker descriptor file will cause the ILLink task to report an exit code and not much else when used as part of dotnet publish.

<linker>
  <assembly fullname="'System.Resources.ResourceManager">
  </assembly>
</linker>

Notice the random single-quote.

The real error isn't great and is buried in higher verbosity logs.

    Fatal error in IL Linker
    Unhandled Exception: Mono.Linker.Steps.XmlResolutionException: Failed to process XML description: <unspecified> ---> System.NullReferenceException: Object reference not set to an instance of an object.
       at Mono.Linker.LinkContext.ResolveReferences(AssemblyDefinition assembly)
       at Mono.Linker.Steps.ResolveFromXmlStep.ProcessAssemblies(LinkContext context, XPathNodeIterator iterator)
       at Mono.Linker.Steps.ResolveFromXmlStep.Process()
       --- End of inner exception stack trace ---
       at Mono.Linker.Steps.ResolveFromXmlStep.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.Execute(String[] args, ILogger customLogger)
       at Mono.Linker.Driver.Main(String[] args)
    Errors

Activity

  1. assigned and unassigned on Aug 23, 2019
  2. self-assigned this
    on Aug 23, 2019
  3. tlakollo commented on Aug 23, 2019

    @tlakollo
    Contributor

    This is a failure during _RunILLink task, the current command line adds as ExtraArgs -out "obj\Debug\netcoreapp3.0\win10-x64\linked" -c copyused -u copyused -l none --skip-unresolved true eventually code fails during Assembly Resolution with an AssemblyResolutionException (AssemblyResolver.cs) instead of throwing an error since --skip-unresolved flag was active, a warning message is printed stating that we couldn't resolve the assembly followed by the name of the skipped assembly (a much more useful warning message). Once again, this message is not being printed in the console since an additional --verbose flag needs to be passed to the _RunILLink task in order to print these warning statements.
    Then second issue is that, after the AssemblyResolutionException has been handled, we return the assembly as null, later on in LinkContext.cs gets operated generating the System.NullReferenceException. This generates two problems, one is that this is not what we expect, we are expecting to skip the assembly, therefore there should be no failure. Second, independent of the error Standard Error does not have enough verbosity to be printed. No matter where do we fail or what the failure is, it's not going to be printed.

    So the fix has the following:

    • Increase Standard Error output logging importance so default verbosity is able to print it
    • Add additional warning if there is a suspicious character on the assembly name (usage of ', :, #, @, !, etc.). This may enter into discussion since ECMA-335 says that all unicode standard 3.0 characters are supported in assembly names, so if a library is called 'System.Resources.ResourceManager is actually going to load it (we tested some ♫☺☼╠.dll and was able to load). Still this warning message it's only going to be printed if we fail to load the assembly, trying to help the user to find what's wrong.
    • Change code to really skip the assembly and not to fail with System.NullReferenceException
    • Change verbosity of the _RunILLink task to include --verbose (notice that this change is not on the linker repo, therefore an additional commit will fix it in sdk repo)
  4. added a commit that references this issue on Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions