With the introduction of Visual Studio 2017, Microsoft added some optimizations to how a project file can be set up. However, no tooling was made available that performed this conversion as it was not necessary to do since Visual Studio 2017 would work with the old format too.
This project converts an existing csproj to the new format, shortening the project file and using all the nice new features that are part of Visual Studio 2017.
There are a number of things that new project system handles differently that are performed by this tool:
- Include files using a wildcard as opposed to specifying every single file
- A more succinct way of defining project references
- A more succinct way of handling NuGet package references
- Moving some of the attributes that used to be defined in AssemblyInfo.cs into the project file
- Defining the NuGet package definition as part of the project file
- Some packages and assemblies don't need to be included since they are now a part of SDK.
- nodes no longer have to be specified
- Optionally migrate to netstandard 2.0 (see switches below)
Using the tool is simple, it is a simple command line utility that has a single argument (as well as some optional switches see below) being the project file you would like to convert. You can also give a directory path and the tool will discover all csproj files nested in it.
For example
Project2015To2017.exe "D:\Path\To\My\TestProject.csproj"
Or
Project2015To2017.exe "D:\Path\To\Solution\Directory"
After confirming this is an old style project file, it will start performing the conversion. When it has gathered all the data it needs it first creates a backup of the old project file (suffixed with .old) and then generates a new project file in the new format.
- If the .vspscc file is found near the .csproj file then the following property group gets generated
<SccProjectName>SAK</SccProjectName>
<SccProvider>SAK</SccProvider>
<SccAuxPath>SAK</SccAuxPath>
<SccLocalPath>SAK</SccLocalPath>
All switches could be specified in long (prefixed with --) or short (prefixed with -) form.
-
--netstandard (-n) - replace target platform moniker with netstandard2.0
-
--assemblyinfo (-a) - use the AssemblyInfo.cs file instead of embeding its contents into .csproj file. This results in generating set of GenerateAssembly_Attribute with false values to prevent build system form generating assembly info nodes and complaining about duplicates.
-
--versions (-v) - generate Version and FileVersion nodes with values from AssemblyInfo file. These nodes are not generated by default.
-
--del_old (-d) - deletes AssemblyInfo.cs.old (and Properties directory if it is empty) and packages.config.old files. This option does not delete .csproj.old file though.
-
--del_tfs_settings (-t) - deletes tfs settings file .vspscc from directory with .csproj.
-
--compile_items (-c) - includes Compile items definitions from old project file in a new one as-is. Since Compile nodes are no longer required (see Default compilation includes in .NET Core projects) this option is off by default. If the switch is specified a following node gets generated in main property group
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
-
--content_items (-o) - includes Content items definitions from old project file in a new one as-is. Since Content nodes are no longer required (see Default compilation includes in .NET Core projects) this option is off by default. If the switch is specified a following node gets generated in main property group
<EnableDefaultContentItems>false</EnableDefaultContentItems>