Retrace will reach End of Life on March 31, 2027. Click here to learn more.

Using xproj and csproj with .NET Core v1 & VS2015

By: mwatson
  |  July 11, 2016
Using xproj and csproj with .NET Core v1 & VS2015

.NET Core is here! We have been busy doing quite a bit of work with it. We have multiple client libraries for sending data to the Stackify API (for metrics, errors, logs, etc.). To ensure that all of our customers can send us data for their .NET Core apps, we have ported them over. So what’s the issue? How do you use both csproj and xproj?

We need csproj so we can build our apps with our existing toolchain, which relies on msbuild. We also need to reference some shared libraries across multiple different apps. Luckily, with Core 1.0 you can use both csproj and xproj at the same time by having different solution files.

Another major obstacle is the project.json file. This file is new for most developers working with .NET Core, but it isn’t actually new (it is also being utilized by universal Windows apps). If you add a project.json file to your application folder, your csproj will start trying to use it. It actually works great and can replace your packages.config and do a good job of setting project package dependencies for non core apps.

Another issue you run into is as soon as you add a .NET Core framework target to project.json, your csproj won’t know what the heck to do it with it.

Enter the Workaround!

The way to fix this is to have two “project.json” files:

  1. The first file is a csproj that basically does nothing. Name it something like “projectname.project.json.”
  2. The second file should be named the normal project.json for your actual Core app. Luckily there is some hackery in msbuild and the Visual Studio tools that allows this to work.

Here is how our this sample project “Profiler.Models” looks on disk:

In this example, Profiler.Models.project.json is picked up by our csproj project. Our xproj for .NET Core properly reads the “project json,” and both can compile and build correctly. MSBuild can still build our normal solution with all our csproj based projects. Mission accomplished!

Here is what your “Profiler.Models.project.json” type file should contain. It is just a simple placeholder config.

{  “runtimes”: {    “win”: {}  },  “frameworks”: {    “net45”: {}  }}

I did see a little oddity when trying to add a new package dependency to my csproj. It added it to my Profiler.Models.project.json and things got a little weird, so watch out for that. I ended up deleting all my project.json files in the folder temporarily, adding the package to my csproj and then reverting my project.json deletes via git so they came right back. I kept my Profiler.Models.project.json clean and empty. You might be able to actually use it to manage all the dependencies for your cspoj.

Both Prefix & Retrace APM work with .NET Core!

 

Stackify Retrace APM for .NET Core

Improve Your Code with Retrace APM

Stackify's APM tools are used by thousands of .NET, Java, PHP, Node.js, Python, & Ruby developers all over the world.
Explore Retrace's product features to learn more.

Learn More
togel slot situs toto pucuk4d agb99 togel toto slot toto togel toto slot indobet situs toto toto slot toto slot toto slot toto toto situs toto toto slot slot depo 10k toto togel 8kuda4d toto judi bola kenangan4d toto situs toto toto toto toto situs toto toto toto slot bobatoto daftar situs toto logototo situs toto situs toto toto bydplay patentoto situs toto slot 4D situs toto leon188 situs toto slot gacor terbaru toto toto slot toto situs toto situs toto MORFINTOTO ilmutoto toto mix parlay bayitoto toto toto toto toto ilmutoto toto toto mawar800 login popotogel prize hongkong malam ini toto slot gacor joker11 toto slot pucuk4d lingkartoto lingkartoto Pucuk4D Login PREMANTOTO UGSLOT slot gacor slot gacor slot gacor AMANAHTOTO toto lingkartoto lingkartoto toto situs toto ilmutoto toto slot gacor rp888 https://foundvinylrecords.com/ depo 5k slot gacor toto slot gacor toto toto panen100 semibola slot gacor Pakde4D situs gacor MySlot188 SlotPoker188 toto togel 77ag monk4d popo togel tikus4d https://asupantoto.co/ Login Batak5D pompa4d lingkartoto Pakde4D lingkartoto
togel slot situs toto pucuk4d agb99 togel toto slot toto togel toto slot indobet situs toto toto slot toto slot toto slot toto toto situs toto toto slot slot depo 10k toto togel 8kuda4d toto judi bola kenangan4d toto situs toto toto toto toto situs toto toto toto slot bobatoto daftar situs toto logototo situs toto situs toto toto bydplay patentoto situs toto slot 4D situs toto leon188 situs toto slot gacor terbaru toto toto slot toto situs toto situs toto MORFINTOTO ilmutoto toto mix parlay bayitoto toto toto toto toto ilmutoto toto toto mawar800 login popotogel prize hongkong malam ini toto slot gacor joker11 toto slot pucuk4d lingkartoto lingkartoto Pucuk4D Login PREMANTOTO UGSLOT slot gacor slot gacor slot gacor AMANAHTOTO toto lingkartoto lingkartoto toto situs toto ilmutoto toto slot gacor rp888 https://foundvinylrecords.com/ depo 5k slot gacor toto slot gacor toto toto panen100 semibola slot gacor Pakde4D situs gacor MySlot188 SlotPoker188 toto togel 77ag monk4d popo togel tikus4d https://asupantoto.co/ Login Batak5D pompa4d lingkartoto Pakde4D lingkartoto