Update: this refers to the outdated set of .net core tools built around project.json, this question and its answers have very limited utility in current .net core tools such as Visual Studio 2017+.
Using Visual Studio 2015, update 3, I'm trying to figure out the existing limitations that may prevent me from doing the following:
For one C # code base, compile the full version of the .net framework and the PCL version and .net kernel class library from the same sources.
Solution dir solutiondir\ will contain the src\ directory containing a projectdir\ ( Solutiondir\src\projectdir ).
Projectdir will contain the HelloWorldPCL class library, which is built as a classic .net PCL project, as well as with other infrastructure objects.
From the same Projectdir the same HelloWorldPCL will also be compiled for the .net 4.6 project.
From the same Projectdir the same HelloWorldPCL will also be compiled for .net core .
All output builds described above will share access to a single set of C # code, which can have conditional definitions #if DOTNET and #if NET46 and #if PCL to handle things that are not available in different frameworks / environments.
So far, I could do most of the above, but when I try to have Projectdir contain a .net core artifact like project.json or HelloWorldCore.xproj , the IDE gives me a lot of errors if I try to create a separate .csproj and .xproj in the same folder, so it seems like this is not the right way.
With a working .csproj project, when I introduced .xproj and a project.json to the disk, but we did not add them to the solution itself, they just sit on the disk next to the real sources of the project, I get a Nuget package recovery error that can be deleted, deleting the project.json file, so itβs not possible to have .csproj in the project directory and also to have the project.json folder. You need to choose between project.json mode ( .net core project style) and .csproj (classic C # project style).
I created a βbrokenβ code base that demonstrates the impossibility of using a folder containing both .csproj and project.json , and then tries to create a csproj project and project.json without intervention:
https://bitbucket.org/wpostma/helloworldcoreandpcl
Question : is there any way to create a project from one set of source files in C #, and as goals - a complete assembly of .net 4.6 , as well as our own class .net core library, as well as a PCL assembly that can be aimed at which Is there a specific .net profile?
Objection:. You can rightfully ask: "Shouldn't you use only one PCL and did with it, and also forget targeting the full .net or creating a separate .net core class library DLL?". Perhaps if the code could be built once, from one source without any conditional definitions and without any differences in functionality, and if the restrictions imposed by the profile method with the minimum common denominator PCL "netstandard" would be sufficient. But what about cases where this is not even possible?
Should we have some kind of complex build process where we either copy the project files or move the source code to achieve a single .cs source file that defines a multiple .net nerdvana profile? Or do I not see alternative solutions?
Refresh . There seems to be a problem with the Visual Studio IDE that prevents the direct linking of the class library to your solution when you create it using project.json instead of using .csproj . However, the solution below indicates that you must create your project and then create the nuget package using dotnet pack . If you look at my modified demo here, you can pack.cmd the file that contains the steps that I used to package the nuget package, and then locally βpublishβ it to the nuget file (local directory) for personal use.