runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Console Application (Package) build error. You must add a reference to assembly 'mscorlib'

Open cheers00 opened this issue 11 years ago • 7 comments

I just downloaded 2015 RC and to build Console app with package option. I added a nuget package System.Diagnostics.Debug using package manager. But I am getting compilation error at Debug.Writeline("test").

How to add reference to mscorlib?

Severity    Code    Description Project File    Line
Error   CS0012  The type 'Object' is defined in an assembly that is not referenced. 
You must add a reference to assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, 
             PublicKeyToken=7cec85d7bea7798e'.  ConsoleApp1.DNX Core 5.0    

cheers00 avatar Apr 30 '15 20:04 cheers00

cc @ericstj

What sort of console application are you creating here?

weshaggard avatar May 02 '15 07:05 weshaggard

This is the new DNX project system. What version of the package did you add? Can you show your project.json?

davidfowl avatar May 02 '15 10:05 davidfowl

@weshaggard this console app looks more like CTP6 app.net console app.

@davidfowl

DNX version is 1.0.0-beta4-11566

{
    "userSecretsId": "aspnet5-CmdApp1-20150430011337",
    "version": "1.0.0-*",
    "description": "",
    "authors": [ "" ],
    "tags": [ "" ],
    "projectUrl": "",
    "licenseUrl": "",

    "dependencies": {
    },

    "commands": {
        "CmdApp1": "CmdApp1"
    },

    "frameworks": {
        "dnxcore50": {
            "dependencies": {
                "System.Console": "4.0.0-beta-22816",
                "System.Collections": "4.0.10-beta-22816",
                "System.Linq": "4.0.0-beta-22816",
                "System.Threading": "4.0.10-beta-22816",
                "Microsoft.CSharp": "4.0.0-beta-22816"
            }
        }
    }
}

cheers00 avatar May 06 '15 03:05 cheers00

@weshaggard @davidfowl

I still have this issue. I even tried DNX on command line. Set coreclr x64 as active and tried to execute but I still get the same error.

cheers00 avatar May 11 '15 21:05 cheers00

Same here just a basic lib project dnxcore50 and Debug.writeline not supported.

"dependencies": { "System.Runtime.Extensions": "4.0.10-beta-22816", "System.Threading.Thread": "4.0.0-beta-22816", "System.Threading.Timer": "4.0.0-beta-22816", "System.Console": "4.0.0-beta-22816", "System.Diagnostics.Debug": "4.0.10-beta-22816", "System.Runtime": "4.0.20-beta-22816" },

"frameworks": {
    //"dnx451": { },
    "dnxcore50": {
        "dependencies": {
            "System.Collections": "4.0.10-beta-22816",
            "System.Linq": "4.0.0-beta-22816",
            "System.Threading": "4.0.10-beta-22816",
            "Microsoft.CSharp": "4.0.0-beta-22816"
        }
    }
}

bklooste avatar May 18 '15 10:05 bklooste

I've experienced this same issue tonight and I think that I've tracked down the setting in VS that causes it. It appears related to the "Produce outputs on build" setting. Turning this on seems to cause the error for me, turning it off no longer causes the error.

Nothing special was shown in VS's activity log, so I've enabled the diagnostic output for MSBuild and here is the difference between setting on/off: https://www.diffchecker.com/lh0nmyw6

HTH

ghost avatar Jun 02 '15 23:06 ghost

Thanks @sblackler for the workaround. Given there has been no further activity on this issue I'm assuming folks are unblocked or no longer hitting this so I'm closing.

weshaggard avatar Oct 28 '15 00:10 weshaggard