Ilasm.exe injects mscorlib dependency in .NET Standard 2.0 dll

705 Views Asked by At

I'm building a .NET Core 2.0 library from IL. I earlier did exactly the same for .NET Core 1.0/1.1 with no issues. However, the same thing does not work for .NET Core 2.0 dll.

After running this:

C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\ilasm.exe /OUTPUT=output.dll /nologo  /quiet /dll /resource=input.dll.res /ssver=6.0 input.dll.il

I'm getting this warning:

warning : Reference to undeclared extern assembly 'mscorlib'. Attempting autodetect

As a result, mscorlib does appear as dependency in the output.dll (and I don't want it to be there).

In the input.dll.il (and res file too), mscorlib is not mentioned at all (mscorlib string never appears in the file, I double-checked this):

//  Microsoft (R) .NET Framework IL Disassembler.  Version 4.6.1055.0
//  Copyright (c) Microsoft Corporation.  All rights reserved.

// Metadata version: v4.0.30319
.module extern 'advapi32'
.module extern 'kernel32'
.module extern 'Kernel32'
.module extern 'Ncrypt'
.module extern 'crypt32'
.module extern 'Crypt32'
.module extern 'secur32'
.assembly extern 'netstandard'
{
  .publickeytoken = (CC 7B 13 FF CD 2D DD 51 )                         // .{...-.Q
  .ver 2:0:0:0
}
.assembly extern 'Microsoft.Win32.Registry'
{
  .publickeytoken = (B0 3F 5F 7F 11 D5 0A 3A )                         // .?_....:
  .ver 4:1:0:0
}
.assembly 'MyLibrary'
{
...

I tried to copy netstandard.dll in the working folder with no effect. Maybe with .NET Core 2.0 a special version of ilasm.exe is needed? I'm using the one from .NET Framework 4.5 as I didn't find any ilasm in .NET Core 2.0 SDK (maybe I search in wrong places). Or what else could be the reason?

The only difference for .NET Core 1.0 (which worked fine) was that .assembly extern 'netstandard' was .assembly extern 'System.Runtime'.

1

There are 1 best solutions below

1
mletterle On

There is a related issue for the .NET Core ilasm (which presumably was forked from the full framework's): https://github.com/dotnet/coreclr/issues/10590