4

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'.

Alex
  • 2,469
  • 3
  • 28
  • 61
  • 2
    Looks like a pretty fundamental issue right now with no bugfix expected any time sooner than v2.1. If then. 2.0 is merely available, it hasn't been debugged sufficiently yet. Fwiw: with a hard dependency on stuff that is only usable on Windows desktop, you don't get any real mileage out of netstandard. – Hans Passant Aug 18 '17 at 13:57
  • Thanks.. As for Registry dep, it's not critical there. The library still works on other platforms, just with a limited functionality. – Alex Aug 18 '17 at 15:45

1 Answers1

2

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

mletterle
  • 3,968
  • 1
  • 24
  • 24
  • Thanks. Tried their ".assembly extern netstandard as mscorlib " suggestion but it just changed the error message to "Reference to undeclared extern assembly 'netstandard'. Attempting autodetect". – Alex Aug 18 '17 at 16:07