Trying out “dotnet new” template updates and csproj with VS2017 (by Scott Hanselman)

I updated my Visual Studio 2017 RC installation today. Here’s the release notes. You just run "Visual Studio Installer" if you’ve already got a version installed and it updates. The updating processes reminds me a little of how Office 365 updates itself. It’s not as scary as VS updates of the past. You can download the VS2017 RC at and it works side by side with your existing installs. I haven’t had any issues yet.

It also added/updated a new .NET Core SDK. I am a fan of the command line "dotnet.exe" tooling and I’ve been pushing for improvements in that experience. A bunch of stuff landed in this update that I’ve been waiting for. Here’s dotnet new:

C:\Users\scott\Desktop\poop> dotnet new
Template Instantiation Commands for .NET Core CLI.

Usage: dotnet new [arguments] [options]

  template  The template to instantiate.

  -l|--list         List templates containing the specified name.
  -lang|--language  Specifies the language of the template to create
  -n|--name         The name for the output being created. If no name is specified, the name of the current directory is used.
  -o|--output       Location to place the generated output.
  -h|--help         Displays help for this command.
  -all|--show-all   Shows all templates

Templates                                 Short Name      Language      Tags
Console Application                       console         [C#], F#      Common/Console
Class library                             classlib        [C#], F#      Common/Library
Unit Test Project                         mstest          [C#], F#      Test/MSTest
xUnit Test Project                        xunit           [C#], F#      Test/xUnit
Empty ASP.NET Core Web Application        web             [C#]          Web/Empty
MVC ASP.NET Core Web Application          mvc             [C#], F#      Web/MVC
Web API ASP.NET Core Web Application      webapi          [C#]          Web/WebAPI
Solution File                             sln                           Solution

    dotnet new mvc --auth None --framework netcoreapp1.0
    dotnet new console --framework netcoreapp1.0
    dotnet new --help

There is a whole new templating engine now. The code is here and you can read about how to make your own templates or on the wiki.

I did a "dotnet new xunit" and it made the csproj file and a Unit Test. Here’s what’s inside the csproj:

That’s not too bad. Here’s a a library with no references:

Note there’s no GUIDs in the csproj. Sweet.

Remember also that there was talk that you wouldn’t have to edit your csproj manually? Check this out:

C:\Users\scott\Desktop\poop\lib> dotnet add package Newtonsoft.Json
Microsoft (R) Build Engine version 15.1.545.13942
Copyright (C) Microsoft Corporation. All rights reserved.

  Writing C:\Users\scott\AppData\Local\Temp\tmpBA1D.tmp
info : Adding PackageReference for package 'Newtonsoft.Json' into project 'C:\Users\scott\Desktop\poop\lib\lib.csproj'.
log  : Restoring packages for C:\Users\scott\Desktop\poop\lib\lib.csproj...
info :   GET
info :   OK 1209ms
info :   GET
info :   OK 181ms
info : Package 'Newtonsoft.Json' is compatible with all the specified frameworks in project 'C:\Users\scott\Desktop\poop\lib\lib.csproj'.
info : PackageReference for package 'Newtonsoft.Json' version '9.0.1' added to file 'C:\Users\scott\Desktop\poop\lib\lib.csproj'.

Doing "dotnet add package" automatically gets the package from NuGet and adds it to your csproj. Just like doing "Add NuGet Package" (or add reference) in Visual Studio. You don’t even have to open or look at your csproj.

I’m going to keep digging into this. We’re getting into a nice place where someone could easily make a custom template then "nuget in" that templates then "File | New | Your Company’s Template" without needed yeoman, etc.

Please shared your feedback:

Also, be sure to check out the new and growing Docs site at

Sponsor: Track every change to your database. See who made changes, what they did, & why, with SQL Source Control. Get a full version history in your source control system. See how with Red Gate’s SQL Source Control.

© 2016 Scott Hanselman. All rights reserved.

Bir Cevap Yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir