Scott Hanselman

Trying out "dotnet new" template updates and csproj with VS2017

February 07, 2017 Comment on this post [28] Posted in Open Source | VS2017
Sponsored By

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 https://www.visualstudio.com and it works side by side with your existing installs. I haven't had any issues yet.

New Templating Engine for .NET Core CLI

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]

Arguments:
template The template to instantiate.

Options:
-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

Examples:
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 https://github.com/dotnet/templating 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:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170123-02" />
    <PackageReference Include="xunit" Version="2.2.0-beta5-build3474" />
    <PackageReference Include="xunit.runner.visualstudio" Version="2.2.0-beta5-build1225" />
  </ItemGroup>
</Project>

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

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard1.4</TargetFramework>
  </PropertyGroup>
</Project>

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 https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json
info : OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/index.json 1209ms
info : GET https://api.nuget.org/v3-flatcontainer/newtonsoft.json/9.0.1/newtonsoft.json.9.0.1.nupkg
info : OK https://api.nuget.org/v3-flatcontainer/newtonsoft.json/9.0.1/newtonsoft.json.9.0.1.nupkg 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 foo.bar" 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 https://docs.microsoft.com/en-us/dotnet


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.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

NXTA - NexTech Africa Conference - Day 1 perspectives

February 04, 2017 Comment on this post [6] Posted in Africa | Musings
Sponsored By

imageI'm in Nairobi, Kenya this week attending a fantastic event called NexTech Africa. It is a free event that showcases the best of what Africa's Startup community has to offer. This event is mostly focused on East Africa's tech community but it included delegates from all over the continent. I'm told over 1000 people are here.

My wife is Zimbabwean and we have family all over in places like South Africa, Tanzania, and Zimbabwe, and friends in a dozen other countries. I personally feel that access to technology and technical education is a fantastic way to help Africa's burgeoning middle class.

However, this trip was for listening. It's silly for me (or anyone who isn't living on the continent) to fly in and "drop the knowledge" and fly out. In fact, it's condescending. So I'm spending this week visiting startups, talking to engineers, university students, and tech entrepreneurs.

I spoke at length with the engineers at BRCK, a Kenya-based startup that has a "brick" that's a portable router, NAS, Compute Module, Captive Portal, and so much more. They can drop one of these a little outside of town and give wi-fi to an entire area. Even better, there could be hyper-local content on the devices. Folks with 30+Mbps Internet may be spoiled with HD content, but why not have a smart router download TV shows and Movies that can be served (much like movies stored on an airplane's hard drive that you can watch via wi-fi while you fly) to everyone in the local area. The possibilities are endless and they're doing all the work from hardware to firmware to software in-country with local talent.

image

I also visited iHub's Technology Innovation Community and saw where they teach classes to local students, have maker- and hacker-spaces, support a UXLab and host local tech meetups. I'll be hopefully communicating more and more with the new friends I've met and perhaps bring a few of them to the podcast so you can hear their stories yourself.

image

These are uniquely African solutions to problems that Africans have identified they want to solve. I am learning a ton and have been thrilled to be involved. Since I focus on Open Source .NET and .NET Core, I think there's an opportunity for C# that could enable new mobile apps via Xamarin with backends written in ASP.NET Core and running on whatever operating system makes one happy.


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.

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

VIDEO: How to get started with technical public speaking!

January 26, 2017 Comment on this post [9] Posted in Musings
Sponsored By

On .NET is a weekly chat with team members from the .NET team at Microsoft. This week we put together something a little different, and honestly, I think it not only went really well, but I think it's an hour that provides a lot of value that goes well beyond .NET or any technology.

image

We put together a panel of folks at different points in their technical careers. Some just starting to speak publicly and some who've been doing it for 20+ years. Some introverts, some extroverts. Some with speaking or theater experience, others with none. And we talked!

We chatted about how to get started, where you can learn to speak on technical topics, how to form a story arc, how to best utilize your gifts, when to be critical and when to breathe.

It was great fun and included myself, Kendra Havens, Maria Naggaga Nakanwagi, Kasey Uhlenhuth, and Donovan Brown. You can view or download it here on Channel 9, or you can watch it on YouTube embedded below.

Let us know if this kind of content is useful, and if you want to see more in the future.


Sponsor: Big thumbs-up for Kendo UI! They published a comprehensive whitepaper on responsive web design and the best and fastest way to serve desktop and mobile web users in a tailored and cost-effective manner. Check it out!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Solved and Fixed: StreetPass stopped working on Nintendo 3DS XL

January 25, 2017 Comment on this post [1] Posted in Gaming
Sponsored By

Nice to meet you! says my MiiYes, this is kind of a silly blog post but it's been bugging me for months so I wanted to get it out there in case it helps someone who is googling for the answer!

I have a little Nintendo 3DS XL (the "new" one) that I bought for long trips. It's a great little device with a large library of games, plus it plays SNES classics like Super Metroid. All in all, I'm thrilled with the purchase.

It has wifi, and both Netflix and Hulu in a pinch for the kids, but it also has some really cool social features using a proprietary wifi connection called "StreetPass." The nutshell is that if you pass by someone (within 30-40 feet in my experience) their "Mii" avatar will jump into your game console and bring with it data from other games.

There's simple stuff like Puzzles, there's mini games like Find Mii, and StreetPass enhances more complex games like Mario World or Resident Evil: Revelations by adding in whole new components. In Resident Evil you'll get communications and weapons drops from your colleagues who are apparently fighting zombies at the same time as you. In Shovel Knight you can race the "ghost" of another player. It's safe and anonymous.

If you travel it's even cooler as you'll StreetPass people in airports and collect their countries or states of origin. I carry my 3DS to conventions and all over the world. It's a hoot.

BUT. A few months back it stopped StreetPassing. Nothing happened, ever. I made sure everything was updated, turned it on and off, but nada.

Recently I fixed it and I'm sure it will fix StreetPass for you also.

  • Go into Mii Maker and design a secondary Mii. Doesn't matter what it looks like. I did it quickly.
  • Switch to that secondary Mii. You won't lose anything.
  • Exit Mii Maker, then go back in and switch back to your original Mii.
    • I surmise that this clears things out and re-writes some settings for you.
    • I also changed my Mii's hat and outfit just to make sure it was re-written completely.
  • Head over to Mii Plaza and you should be all set.

My system started StreetPassing within a few hours.

Photo Jan 24, 9 59 42 PM

I hope this helps someone because as a traveller who really digs StreetPass, having it not work was really harshing my mellow. By the way, I REALLY love this "DreamGear" rubber case I got for my 3DS. It changes the shape of it, makes it larger, almost like an Xbox controller. That's an Amazon link that you can use that will help me get more 3DS games. ;)


Sponsor: Big thumbs-up for Kendo UI! They published a comprehensive whitepaper on responsive web design and the best and fastest way to serve desktop and mobile web users in a tailored and cost-effective manner. Check it out!

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Working with Multiple .NET Core SDKs - both project.json and msbuild/csproj

January 21, 2017 Comment on this post [9] Posted in
Sponsored By

As .NET Core and ASP.NET Core make the transition from project.json style project files to MSBuild (csproj) style files, I'm starting to get myself up to speed on what's needed, what's changing, and why/if it's a good thing. Documentation is still getting updated but there's a great blog post from Nate McMaster who works on the team.

As I touched on in a previous post, you can continue working on project.json based projects while experimenting with the newer stuff. Here I have a global.json with the version pinned to an earlier SDK. Then I move to another folder and the .NET CLI gives me another version. Projects can remember and pin their SDK versions.

Global.json is useful

This is assuming that you do have multiple versions (and the ones you want) installed:

Here I have 4 SDKs installed and I can see them in my installation folder

To be clearer, I'll run "dotnet new" in one folder and again run "dotnet new" in another. Note that one has global.json pinned older "LTS" (Long Term Support) SDK with project.json and one will use the later "Current" (bleeding-edge) stuff.

See how that works?

C:\Users\scott\Desktop\csprojstuff> dotnet new
Created new C# project in C:\Users\scott\Desktop\csprojstuff.

C:\Users\scott\Desktop\csprojstuff> dir
Volume in drive C is Windows
Volume Serial Number is 00C1-AED2

Directory of C:\Users\scott\Desktop\csprojstuff

01/23/2017 01:09 PM <DIR> .
01/23/2017 01:09 PM <DIR> ..
12/07/2016 09:49 PM 422 csprojstuff.csproj
12/07/2016 09:49 PM 133 Program.cs
2 File(s) 555 bytes
2 Dir(s) 149,845,356,544 bytes free

C:\Users\scott\Desktop\csprojstuff> cd ..\projjsonstuff

C:\Users\scott\Desktop\projjsonstuff> dotnet new
Created new C# project in C:\Users\scott\Desktop\projjsonstuff.

C:\Users\scott\Desktop\projjsonstuff> dir
Volume in drive C is Windows
Volume Serial Number is 00C1-AED2

Directory of C:\Users\scott\Desktop\projjsonstuff

01/23/2017 01:10 PM <DIR> .
01/23/2017 01:10 PM <DIR> ..
01/23/2017 01:05 PM 95 global.json
06/21/2016 07:10 PM 214 Program.cs
06/21/2016 07:10 PM 367 project.json
3 File(s) 676 bytes
2 Dir(s) 149,844,484,096 bytes free

Now I can also "migrate" that project.json forward with "dotnet migrate." That's a NEW command so look what happens if I just run it locally there without changing the global.json pinned SDK version? Doesn't work. For this example I'll delete global.json and run it again.

C:\Users\scott\Desktop\projjsonstuff> dotnet migrate
No executable found matching command "dotnet-migrate"

C:\Users\scott\Desktop\projjsonstuff> del global.json

C:\Users\scott\Desktop\projjsonstuff> dotnet migrate
Project projjsonstuff migration succeeded (C:\Users\scott\Desktop\projjsonstuff)
Summary
Total Projects: 1
Succeeded Projects: 1
Failed Projects: 0


C:\Users\scott\Desktop\projjsonstuff> dir
Volume in drive C is Windows
Volume Serial Number is 00C1-AED2

Directory of C:\Users\scott\Desktop\projjsonstuff

01/23/2017 01:11 PM <DIR> .
01/23/2017 01:11 PM <DIR> ..
01/23/2017 01:11 PM <DIR> backup
06/21/2016 07:10 PM 214 Program.cs
01/23/2017 01:11 PM 944 projjsonstuff.csproj
2 File(s) 1,158 bytes
3 Dir(s) 149,843,054,592 bytes free

Again, go check out Nate's excellent blog on the topic. He also covers briefly how you can publish "Standalone" or "Self-Contained" Deployments, and points out that in MSBuild world, all projects are portable until you decide to target a runtime:

dotnet publish --framework netcoreapp1.0 /p:RuntimeIdentifier=osx.10.11-x64

More on this as it comes!


Sponsor: Do you deploy the same application multiple times for each of your end customers? The team at Octopus have taken the pain out of multi-tenant deployments. Check out their latest 3.4 release

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook bluesky subscribe
About   Newsletter
Hosting By
Hosted on Linux using .NET in an Azure App Service

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.