Console Application (Package) build error. You must add a reference to assembly 'mscorlib'
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
cc @ericstj
What sort of console application are you creating here?
This is the new DNX project system. What version of the package did you add? Can you show your project.json?
@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"
}
}
}
}
@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.
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"
}
}
}
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
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.