I am quite new to .Net Core and I am having an issue when trying to reference a .Net Core Class Assembly Project from my .Net Core Console Application. It is a very similar issue to this question, however the answers here did not help me.
I am using Visual Studio 2015 Update 3
I am using ReSharper Ultimate 2016.1.2
I am using .Net Core 1.0.0 Preview 2 (RC2)
.Net Core Class project
Class1.cs
namespace ClassLibrary1
{
public class Class1
{
public void Foo()
{
Console.WriteLine("Foo");
}
}
}
project.json
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.6"
},
"frameworks": {
"netstandard1.6": {
"imports": "dnxcore50"
}
}
}
.Net Core Console project
Program.cs
using System;
using ClassLibrary1;
namespace ConsoleApplication
{
public class Program
{
Class1.Foo();
}
}
project.json
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
},
"ClassLibrary1": "1.0.0-*"
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
I can successfully add a project reference to ClassLibrary1 in ConsoleApplication, this adds the reference and results in the dependency being added to my project.json in ConsoleApplication however when I try to use the reference eg. ClassLibrary1.Class1.Foo(); Visual Studio fails to find the code, fails to build.
ReSharper highlights my code as Red like the question above, and does offer to add the reference, however this does nothing.
I have tried to answers in the linked question, which didn't work for me, and I'm not sure it is ReSharper with the issue as Visual Studio just won't compile the code, which doesn't have a bearing on ReSharper.
If I change the dependency and framework of my Class1 in the project.json from netstandard1.6 to netcoreapp as below, this does work and allows me to reference and use the class as expected in my ConsoleApplication. However, this seems rather hacky to me and my understanding is that netcoreapp is a dependency used for a runnable assembly, and netstandard should be the dependency for a regular class library?
Does anyone have any thoughts?
Hacked ClassLibrary1/project.json (Does work but seems wrong?)
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}