The common code between the regular .NET library and the base project did not work for me by simply using the Shared project, because I could not reference it from the Core project.
However, with a little trick, I could get it to work.
Let me explain this structure / file:
[ProjectName] // Root of Core project project.json [ProjectName].xproj Shared // Root of Shared project [ProjectName].Shared.projitems [ProjectName].Shared.shproj // -- Source files here -- Net // Root of .NET project [ProjectName].csproj Properties AssemblyInfo.cs // For both Core and .NET project // NO source files here
So, you will need 3 projects, of course: the main project, the regular .NET project and the general project.
The Shared project has all the source files.
The .NET project refers to the Shared project, so it also has these files.
The main project sees all the files of the Shared project, so it also has the same files.
What is it. You can now have common source code files for the .NET and Core project.
A few notes:
- Never put
.shroj and .csproj in the same folder. For me, this completely turned off intellisense in VS (2015). This information was worth a lot of pain for me ...
- You can use
#if -s to fine tune generic code
- You can also use NuGet 2 in a .NET project with the specified folder structure.
- Please note that if you place (NuGet 2)
packages.config in the same folder where (NuGet 3) project.json , the latter will completely overwrite earlier.
source share