Differences between .csproj files in Visual Studio 2013 and 2015

With the release of Visual Studio 2015 (VS2015) came also a brand new version of C# (namely 6.0), as well as the new Roslyn compiler. If you haven't seen all the neat features of C# 6.0, you can read all about them here.

In this blog post I want to address some of details that might come in handy, when either migrating from an old Visual Studio 2013 (VS2013) project, or when creating new Visual Studio 2015 (VS2015) projects - in particular the difference between the .csproj files, and what these mean.

TL:DR;

If you are using VS2015 and have a developer on your team still using an older version of VS, then you need to be aware of the following:

  • The developer needs to be upgraded to VS2015, otherwise you need to make sure that the nuget packages for Roslyn is not removed.

  • If the developer cannot upgrade to VS2015 or the nuget packages and its references are removed, then you need to remove all Roslyn project specific details from all your project files (see below), as well as avoid using C# 6.0 syntax.

The extended explanation

When using VS2015 and creating new projects you'll experience that the project files now include a package.config file, as shown below:

If you open the package.config file, you'll find that there are references to some nuget packages related to the .NET compiler platform, or to be more specific, the Roslyn compiler:

In addition, each project file itself contains quite a bit of Roslyn configuration by default:

The project file actually expects that it can import the nuget packages for Roslyn, and if this isn't the case, Visual Studio fails to build the project.

Key takeaways

When creating new project files using VS2015, you need to be aware that, if you remove the package.config file, then the project will fail to build. Given that the package.config file is removed, you also need to remove the remaining configuration found within the .csproj file (marked be red in the image above). Now you will be able to build the project again.

However, there are some pitfalls related to the above:

  • If you remove the nuget packages and try to compile the project using an older compiler (like VS2013), then the project will not build. This can be rather crucial if you are having one or more developers on your team, which cannot upgrade to the VS2015.

  • If you remove the nuget packages and use VS2015 together with the latest version of ReSharper (supporting C# 6.0 syntax), then ReSharper will by default do anything to re-write you code into C# 6.0 compliant syntax. This can be rather problematic if one of the developers on your team uses VS2013, since neither the IDE or the compiler will recognize the new symbols, and thus the project file will fail to build. In worst case scenario this can be rather time consuming, given that you need to rewrite large portions of your code to the old C# 5.0 syntax.