Using RC2, When i add a reference to a dotnet console or web app from a dotnet class library, it by default does not build and has a dependnecy error.
Now the solution for me was NOT the accepted answer on that stackoverflow. All I had to do was click "restore packages" for the project with the reference error.
Just want to make sure this gets logged and can be fixed for next release.
Can you make a repo solution and push to github? It'll be easier to see if it's a bug or if something is misconfigured.
I have a similar issue. I created a repository to show it:
TestApplicationLibraryReferenceing.
Preconditions
Procedure i have done for creating the console application and the class library:
project.json of the console application:
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-rc2-3002702"
},
"TestClassLibrary": "1.0.0-*"
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
project.json of the class library:
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027"
},
"frameworks": {
"netstandard1.5": {
"imports": "dnxcore50"
}
}
}
global.json
{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview1-002702"
}
}
I am actually now unable to re-create this issue.
All new dotnet core applications I create are no longer having trouble restoring packages when added as a reference.
I also pulled @igeligel 's solution down and tested it, and it worked fine for me as well.
This may only be a rare issue for people with a fresh install of RC2 VS tools.
Have you been using Visual Studio too or just the command line tools?
@igeligel I'm only using visual studio, no command line.
I can confirm that this is a bug but it only happens when you do like this:
Open a project created in RC1.
Start upgrading it to RC2 by changing the global.json
Upgrade you first .dll project to RC2.
Upgrade the project referencing your first .dll project to RC2.
Compile.
Now the first project does not get compiled and the .dll is not copied.
A restart of VS solved my problem.
i'm actually finding that with RC2, after I make a change to my package.json, i'm almost always having to right click the project and click "restore packages" before it will do so.
I have this issue too. I think it's not a small issue, it's totally preventing me from using RC2. :-(
I have cloned igeligel's repo and I have the issue.
Has anybody found an solution since then?
(restarting VS or forcing a restore did not change anything for me). I have also tried to change/remove the global.json to no avail.
This guy seems to have the same issue: http://nticformation.com/solutions_problems.php?tuto=45833&subCategory=asp.net+asp.net-core+asp.net-core-mvc&Category=asp.net
That guy seems to be using resharper, are you also using resharper?
@davidfowl I have disabled resharper back then and it was not working either.
Anyway: Reinstalling the sdk (Important!: SDK Installer) and the the .NET Core Tooling Preview 1 for Visual Studio 2015 helped me. After that and with disabled resharper i was able to reference class libraries.
Also deinstall both first and install .net core sdk first after that.
@davidfowl I have disabled resharper and now it works! Thanks a lot for the tip!
More precisely, disabling the features ASP.NET, ASP.NET MVC and ASP.NET Razor in resharper's options solved my problem.
Edit: not all of it, just disabled resharper ultimate 2016.1.2 entirely. :-) (with VS 14.0.25123.0)
The issue was fixed in EAP 2. They mention it here: https://youtrack.jetbrains.com/issue/RSRP-458862
I have installed this version and the issue is fixed now.
I do not use ReSharper..
I just pulled down a project and installed VS Update 3 and dotnet sdk 1.0 preview 2 tools.
The first time i opened the solution, the project would not build, and i had to right click one of the projects and click "restore", which then caused all the projects to restore packages and then were able to build successfully.
I have the similar issue.
using ASP.NetCore Template 1.0.0 as Startup Project and other class libraries.
i am able to reference the class libraries to the project but unable to use the namespaces
@SaiKrishnaTej23 I am using core v1.0 - I got this fixed. When you create a class library (.NET Core) you need to edit the project.json file: from: "version": "1.0.0-*", to "version": "1.0.0",
I am having the same issue, but none of the comments seem to fix this for me.
Not using ReSharper and my class Library is not Core.
My project uses Asp.Net Core, but .NET framework 4.5.2 for both Projects in the Solution.
@larsfjerm I can't believe this change fixed it for me too! 馃槄
Not working for me. But producing a NuGet for it using dotnet pack then installing that works.
Just include target framework entry for .netcoreapp in project.json as below and try again. It will work.
"frameworks": {
"netstandard1.6.1": {
"imports": "dnxcore50"
},
"netcoreapp1.1": {
"imports": "dnxcore50"
}
},
I even cannot add a reference to xproj in a .Net4.6.1 Console App. Repro repo https://github.com/OzBob/corespike
Ref xproj line:
https://github.com/OzBob/corespike/blob/master/CoreSpikeReferences/461ConsoleApplication1/461ConsoleApplication1.csproj#L53
and in ref library:
"frameworks": {
"net461": {},
"netstandard1.6": {
"imports": "dnxcore50"
}
}
Any suggestions? As I tempted to build to a 'lib' folder and ref the dll directly, but I feel a bit of my soul wither as I am tempted to upvote the desperate answers: http://stackoverflow.com/a/37639003/1586498
This issue is being closed because it has not been updated in 3 months.
We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.