Visual Studio 2017

If you haven’t tried out Visual Studio 2017 yet you really should. It won’t take long to install either, they totally redesigned the installer so if you have an SSD you should be ready in 10 minutes. #####Common Project System Along with that there is a new project system for Visual Studio projects. This means the big long and ugly .csproj files you were used to can be greatly reduced down to just a handle of lines.

This won’t work for Windows Forms or WPF applications yet, but that will come sometime. Here is an issue you can follow if you are interested in support for those. This will work for .NET Core projects and also class libraries.

NuGet packages

So what does this have to do with NuGet packages? Well I am going to show you how to convert a class libary to the new .csproj format, and then you will see how easy it is to create a NuGet package with Visual Studio.

Getting started

I started by creating a class library project in Visual Studio using .Net 4.6.2. The initial .csproj file looks like this.

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xml.Linq" />
    <Reference Include="System.Data.DataSetExtensions" />
    <Reference Include="Microsoft.CSharp" />
    <Reference Include="System.Data" />
    <Reference Include="System.Net.Http" />
    <Reference Include="System.Xml" />
    <Compile Include="Url.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

Since there is only one class this is not very long compared to how some files get in large projects, but still with the new project system it can be made much shorter. When this is converted to the new format this is what it looks like.

<Project Sdk="Microsoft.NET.Sdk">

    <Reference Include="System.Net.Http" />

I think you will agree that it is much nicer to look and much more readable. The Visual Studio solution explorer also looks a little different when using this new format.

Conversion tip

If you need some help converting your .csproj file you should check this out. There is a lot of helpful information there.

Creating the package

Now if you right click on the Project in Visual Studio and click Properties you will see there is a Package tab on the left. It fills in some of the information based on what I put in the .csproj file. To create a NuGet package all you have to do is check the “Generate NuGet package on build” box and build the project. Then in my bin/Debug folder I see the .nupkg file. With that you could upload it to NuGet or create an internal NuGet feed to use.


So the project I created doesn’t really do much, but hopefully it got the point across of how easy it is to create a NuGet package.

Have you used the new project system? What do you think of it?