Scott Hanselman

Windows 10 "Developer Mode"

July 20, 2016 Comment on this post [96] Posted in Win10
Sponsored By

imageThe new Windows 10 update coming in a few weeks. It's called Windows 10 "Anniversary Edition" (I would have just called it 10.1, because, I dunno, monotonically increasing numbers and all, but whatever) and it has a LOT of really nice refinements.

Windows 10 is continuously updated and has been a few times since release, but this most recent one adds a lot of cool stuff like support for Bash on Ubuntu for Developers. For some folks who say they "wait for version 3" - this coming update is that version 3.

One thing I've noticed - and I'm personally rooting for - is a specific section in Windows Settings that seems to be getting some more love. I'm hoping we (developers and power users) will see some real investment here. If you agree after reading this post, sound off in the comments and maybe someone at Microsoft will notice and agree.

If you go to the Settings app on these newer Windows 10 builds, you'll notice "For Developers" as a new menu item. Now, to be clear, I'm reading into this and likely adding meaning where there may not be, but I love this. It's a formal place in the operating system where I can TELL IT THAT I AM A DEVELOPER. 

I can say "I want this machine to be in developer mode."

image

Under Developer Mode in the Insiders' Builds there is a nice collection of developer and power-user related settings brought together under one roof. What's great about this is that you already know these settings. As a developer you likely install Windows and then immediately go around to Windows Explorer, the Registry, and a bunch of other places to tweak Windows to how you work as a developer.

For example, Windows Explorer. Non-technical parent doesn't need to see Hidden Files or have the Full Path in the Title Bar. But I DO, and those settings are all in one place.

image

Seriously, the "Full path in the title bar" thing is super useful. I used to say "that should be the default." Now I realize that it shouldn't be. It should be the default for Developers.

image

There's other options as well for Remote Desktop, PowerShell, and remote diagnostics.

image

Today this new Developer Mode settings page looks like a nice collection of conveniences, but I really think it's got amazing potential, again as a formal declaration that I am a developer.

In the future I'd love to see (totally brainstorming here as I am not in the Windows department) a quick way to turn on Bash on Ubuntu on Windows 10, or quickly download VSCode or Visual Studio Community, get .NET Core, install Python, install mobile device emulators, install SysInternals or prep my system for remote debugging.

What do YOU think?


Sponsor: Do you deploy the same application multiple times for each of your end customers? The team at Octopus have been trying to take the pain out of multi-tenant deployments. Check out their 3.4 beta 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

Exploring dotnet new with .NET Core

July 18, 2016 Comment on this post [33] Posted in ASP.NET | ASP.NET MVC | DotNetCore | Open Source
Sponsored By

I'm very enjoying the "dotnet" command line. Mostly I do "dotnet new" and then add to the default Hello World app with the Visual Studio Code editor. Recently, though, I realized that the -t "type" and -l "lang" options are there and I wasn't using them. I think they are a little awkward, in that you have to:

dotnet new -t Web

when I think it should be more like dotnet new [type] as in

dotnet new web

What do you think? I find the -t a little heavy. I like the idea of "web" being empty, and "web/mvc" or "web/webapi" having more fleshed out stuff. Even "web/angular," you get the idea. Sound off in the comments. Regardless, there's cool templating tooling coming, I hear, but for now there's more there than I realized.

Of course, there's the default "dotnet new" which is a Hello World console app with a program.cs and project.json. In the future I think it will just run the app, and you'll have to do something like -v verbosity to get the details that we don't usually need to see.

C:\Users\scott\Desktop\test\console>dotnet run
Project console (.NETCoreApp,Version=v1.0) will be compiled because expected outputs are missing
Compiling console for .NETCoreApp,Version=v1.0

Compilation succeeded.
0 Warning(s)
0 Error(s)

Time elapsed 00:00:01.1591124

Hello World!

You can add -l (lang) to it and "dotnet new -l F#" and get an F# Console app rather than a C# one:

C:\Users\scott\Desktop\test\fsharp>dotnet run fabu!
Project fsharp (.NETCoreApp,Version=v1.0) was previously compiled. Skipping compilation.
Hello World!
[|"fabu!"|]

C:\Users\scott\Desktop\test\fsharp>type Program.fs
// Learn more about F# at http://fsharp.org

open System

[<EntryPoint>]
let main argv =
printfn "Hello World!"
printfn "%A" argv
0 // return an integer exit code

There's also "dotnet new -t lib" which is super basic and gives you a quick new project with a Class1 and an Empty Method. Not so useful, but good to know.

You can also "dotnet new -t xunittest" to make a new test project. Nice that this is built-in! Now I just "dotnet test" after a "dotnet restore" and I get test results!

xUnit.net .NET CLI test runner (64-bit win10-x64)
Discovering: testing
Discovered: testing
Starting: testing
Finished: testing
=== TEST EXECUTION SUMMARY ===
testing Total: 1, Errors: 0, Failed: 0, Skipped: 0, Time: 0.146s
SUMMARY: Total: 1 targets, Passed: 1, Failed: 0.

Side Note: If the folder name of the project is the same as one of the dependencies, it can confuse the resolver. For example, I did my new test project in a folder creatively named "XUnit." This is also the name of a dependency. I got the error: Errors in C:\Users\scott\Desktop\test\xunit\project.json Cycle detected:  xunit (>= 1.0.0) -> xunit (>= 2.1.0) -> xunit (>= 2.1.0). Note that 1.0.0 there. That's my project, which is 1.0.0. Solution? Rename my project's containing folder.

There's ASP.NET Core Hello World, which is "dotnet new -t Web." This will give you a nice simple ASP.NET Core app with some simple defaults that's setup for bower, gulp, and npm usage. I anticipate we'll see varying levels of what folks consider "complete."

yo aspnet: dotnet new -t web isn't the only way to make a new ASP.NET Core project from the command line (CLI). You can also use the Yeoman generator or "yo aspnet" to make very interesting projects, as well as create your own generators. In fact, Steve Sanderson has some impressive generators like his "aspnet-spa" generator for making Angular, React, and Knockout Single Page Apps (SPA) with ASP.NET Core.

image

All these generators work on Windows, Mac, and Linux, of course. I believe the intent is to reconcile them all such that Visual Studio proper and Visual Studio Code via the CLI will all get the same "File | New Project" results. Visual Studio will still be more "visual" but everything you can do in one world can and should be possible in another.


Sponsor: Big thanks to Redgate for sponsoring the feed this week. Have you got SQL fingers? Try SQL Prompt and you’ll be able to write, refactor, and reformat SQL effortlessly in SSMS and Visual Studio. Find out more!

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

Self-care matters: Pay yourself first

July 14, 2016 Comment on this post [40] Posted in Musings
Sponsored By

My sonI was meeting with a mentee today and she was commenting how stressed out she was. Overwhelmed with work, email, home, life, dinners, the news, finances...you know. LIFE. I am too. You likely are as well.

We spent about on the phone talking about how to make it better and it all came down to self-care. Sometimes we all need to be reminded that we matter. It's OK to take a moment and be selfish. You are the center of your universe and it's important to take time for yourself - to appreciate your value.

Depending on your personality type, you may give so much of yourself to your family, your work, your family and friends that you forget what's at the core! You! If you don't take care of yourself then how will you take care of everyone else?

This may seem obvious to you. If it does, that's cool. Click away. But sometimes obvious things need to be said and for my mentee and I, today, we needed to hear this and we needed a plan.

Here's some of our ideas.

  • Cancel a meeting.
    • Maybe cancel two. If you look at your day with absolute dread, is there a ball that you can drop safely? Perhaps ask a coworker if they can handle it for you?
  • Pay yourself first
    • Finances are a stressor for everyone. My wife and I used to argue about little $5 debit card things because they not only added up but they filled up the register, were hard to track, and generally distracted us from important stuff like the rent. Now we get an allowance. I don't use a credit card, I have a certain amount of cash each week (we get the same amount). I can buy Amazon Gift Cards or iTunes cards, I can eat at Chipotle whenever, or buy an Xbox game. Now when an Xbox game shows up she is interested in hearing about the game, not sweating how it was purchased. Pay yourself first.
  • Setup Formal Me-Time
    • Once a week my wife and I have a day off. From each other, from the family, just...off. I leave at 5pm and come back late. She does the same. Sometimes I see a movie, sometimes I walk around the mall, sometimes I code or play Xbox. The point is that it's MY TIME and it's formal. It's boxed and it's mine. And her time is hers. You shouldn't have to steal an hour when you're super stressed. PAY yourself an hour, up front.
    • We also do a weekly date night. Always. Gotta prioritize. I hate hearing "we haven't seen a movie or had a dinner in years...you know, kids." Nonsense. Get a sitter from the local uni and pay yourself first with TIME.
  • Self-care
    • Schedule a massage. Have your nails done (everyone should do their nails at least once). Get a haircut. Dance. Clean your office. Sleep. Do whatever it is that feeds your spirit.
  • Say no
    • Sometimes "No. I just can't right now." is enough to stop an email thread or a something when you feel you just can't. Drop the ball. Life is somewhat fault tolerant. Use your judgment of course, but truly, unless your software is saving babies, maybe take a break. Even an hour or a "mental health day" helps me no burn out.

Do you pay yourself first? Do you need to be reminded that you deserve health and happiness? Let me know in the comments.


Sponsor: Big thanks to Redgate for sponsoring the feed this week. Have you got SQL fingers? Try SQL Prompt and you’ll be able to write, refactor, and reformat SQL effortlessly in SSMS and Visual Studio. Find out more!

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

Where's DNVM? Safely running multiple versions of the .NET Core SDK and Tooling with global.json

July 10, 2016 Comment on this post [15] Posted in DotNetCore | Open Source
Sponsored By

On June 27th both the ASP.NET Core and .NET Core 1.0 runtimes were officially released. They are now version 1.0 and are both supported frameworks. However, the "tooling" around .NET Core remains in a Preview state. However, it's really easy and safe to swap between command-line tooling versions.

  • NET Core SDK = Develop apps with .NET Core and the SDK+CLI (Software Development Kit/Command Line Interface) tools
  • .NET Core = Run apps with the .NET Core runtime

You'll see over on the .NET Advanced Downloads page the complete list of downloads including those for Windows, Mac, and several flavors of Linux. It's even supported on RedHat Enterprise Linux...it's surreal to see that RedHat even has .NET Core docs on their site.

Where's DNVM List?

A year ago before ASP.NET Core and .NET Core fully merged and the "dotnet" command line was created, there was a command line tool called "dnvm" or the .NET Version Manager. It would give you a list of the .NET Core runtimes you had installed and let you switch between them. While that exact style of functionality may return as the SDK and tools continues development, you can easily have multiple .NET Core SDKs and CLIs installed and switch between them on a per project basis.

For now, if you want the equivalent to "dnvm list" to see what .NET Core SDKs are installed at a system level, you'll look here.

Where is the .NET Core SDK installed?

When you install the .NET Core SDK on Windows it shows up in C:\Program Files\dotnet\sdk.

C:\Program Files\dotnet\sdk

In this screenshot I have four .NET Core SDKs installed. The SDK that ships with .NET Core 1.0 is 1.0.0-preview2-003121. However, you'll note that I have two newer .NET SDKs installed. Since it's all open source, you can head over to https://github.com/dotnet/cli and scroll down a bit.

There are CI (continuous integration builds) and a complete table of versions that you can download. Be sure to check the Build Status and see that things are passing and healthy, but also have a reason for downloading a daily build.

Know WHY you want a daily build of the .NET Core SDK. Are you checking on a specific bug to see if it's fixed? Is there a new feature that you require?

image

I noticed a specific bug that was bothering me in the Preview 2 tooling. I like to use the new logging system and I like that it uses ANSI Colors when logging to the console. When I go "dotnet run" I get very nice ANSI-colored output. However, when I used "dotnet test" or "dotnet watch," I would lose all my ANSI colors from the same logging calls and just get plaintext. I commented on the GitHub issue here as it's clearly a bug.

ANSI Colors are lost with dotnet watch

It's a cosmetic bug on the way dotnet.exe works with child processes, but it was still annoying to me. The cool part is that when it was/is fixed, as it was with this pull request, I can get a build and install it without fear.

Side by Side .NET Core SDK installs and global.json

I can check the version at the command line like this:

C:\>dotnet --version
1.0.0-preview2-003121

C:\>dotnet --info
.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: 1e9d529bc5

Runtime Environment:
OS Name: Windows
OS Version: 10.0.143xx
OS Platform: Windows
RID: win10-x64

Here I've got the version that shipped with .NET Core 1.0. I want to use the latest one, then go back to my app and use "dotnet watch" or "dotnet test" and see if the bug was really fixed in this version. But what if want my app to be driven by this new dotnet CLI?

I've got a global.json in the root of my solution in c:\lab2 that looks like this. I'm going to change the version to the new one in a moment.

{
"projects": [ "src", "test" ],
"sdk": {
"version": "1.0.0-preview2-003121"
}
}

My projects are in src and my tests are in test, all underneath the main solution folder that contains this global.json file. If the "sdk" section didn't exist, running dotnet --version would pick up the latest one.

If the sdk is "pinned" to a specific version that means that when I run dotnet --version while in this folder or below, I'll get the specific version I've asked for.

Now I'll go to https://github.com/dotnet/cli and install (for example) 1.0.0-preview3-003180. This daily build has the fix for that ANSI bug I care about. Again, you can see this version is installed by looking in the first Windows Explorer screenshot above, and in c:\program files\dotnet\sdk.

Remember that my global.json in my c:\lab2 folder specifies (pinned) preview2? Now running dotnet.exe looks and works like this...read carefully.

C:\lab2>dotnet --version
1.0.0-preview2-003121

C:\lab2>cd ..

C:\>dotnet --version
1.0.0-preview3-003180

C:\>where dotnet
C:\Program Files\dotnet\dotnet.exe

See that? I get preview2 inside the lab2 folder but I get the latest anywhere else. But how?

A little known Windows command line trick is the "where" command. You can say "where notepad" and if there are more than one on the PATH, you'll get a list. However, here there's just one dotnet.exe, but I get different results when I run it in different folders. Exactly how this works is explained in exquisite detail in Matt Warren's post "How the dotnet CLI tooling runs your code" but it LOOKS like this, as viewed in Process Explorer:

DotNet.exe picks up the SDK version from global.json

And when I change the version in global.json to the daily I downloaded?

Here dotnet.exe uses the a newer installed SDK

The dotnet.exe application will look at global.json and then do the right thing. This way I can have lots of projects bring driven by different versions of the "dotnet" command without having to type anything other than "dotnet run" or "dotnet test."

It also allows me to keep using the .NET 1.0 runtime that is released and supported, while quickly testing new tooling features and checking on fixed bugs like this ANSI one that was annoying me.


Sponsor: Many thanks to my friends at Stackify for sponsoring the feed this week! it’s what being a developer is all about so do it the best you can. That’s why Stackify built Prefix. No .NET profiler is easier or more powerful. You’re 2 clicks and $0 away, so build on! Prefix.io.

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

Is your stuff backed up? Recovering from a hardware failure

July 07, 2016 Comment on this post [30] Posted in Musings
Sponsored By

My computer died and I am sadI had a massive hardware failure over the holiday weekend. I can only tell you what I think happened. I'm not an electrical engineer so if you know more (and I'm sure you do), do feel free to share your thoughts in the comments.

For my main machine in my home office I'm running the Ultimate PC that Jeff Atwood was so kind to build for me a few years back. It's not the Ultimate anymore, but I will say it's still VERY competent. I've upgraded the memory, video card, and SSD (more on the SSD in a moment) and it's a great machine and very very fast.

The tower was connected to an APC 850VA UPS that had worked nicely for a while. I replace just the batteries in my UPS's every 18-24 months. This last week the UPS started a low "scream" so I went over to check it out. It had turned off suddenly, so the PC and all the accessories were also off. I turned it back on and there was a series of snaps and pops, another screen, followed by a non-trivial amount of smoke and a burning electrical smell.

When it was all over, the main fuse of the house had popped, the UPS was dead and smoking, and the power supply in my computer was dead and smoking. Ugh.

I headed down to the local electronics shop and bought a new 1000W power supply, a new APC BR1000G, and went to town, rebuilding my machine. After redoing all the cables and stuff...it didn't boot. I didn't even see the hard drive (SSD). The drive is a Crucial c300. I loved this drive and it worked great for like 6 years...and now it's dead. Turns out that these Crucial drives are known to die when they lose power quickly. I tried to bring it back to live using all the various forums and whitepapers about this known issue, but nope. It's dead.

OK, so have I lost data? What now? Fortunately I backup my systems. And I hope you, Dear Reader, also backup as well.

Stop reading this now and please, think about your backups. Do you have one? Have you tested to see if you can restore from your backups?

Backups always succeed. It's restores that fail. Test your backups by restoring from them.

I've got a number of backups because I practice the Backup Rule of Three.

  • 3 copies of anything you care about - Two isn't enough if it's important.
  • 2 different formats - Example: Dropbox+DVDs or Hard Drive+Memory Stick or CD+Crash Plan, or more
  • 1 off-site backup - If the house burns down, how will you get your memories back?

Here's what my backup situation is/was and how I restored.

While you can use Imaging Software and restore an entire image of Windows or Mac, I find that reinstalling Windows takes less than an hour. I keep a bootable USB key of Windows 10 around. You can also download an ISO and make a USB key quickly. You don't usually need an activation key if you're reinstalling Windows. In my case, I installed the new drive, booted off the USB, signed into Windows with my Live ID (Microsoft Account) and it picked up my Windows license already.

Windows File History

I have a 4TB external drive on my desk that uses Windows 10 File History. This is like the Mac Time Machine feature. It's one of the best little "hidden" features of Windows 10 and everyone should use it. It's actually been around for years. My Documents, Desktop, and any other folders I want are automatically backed up as often as I want. I have a backup going every 30 min and I never think about it. It just works, and I don't notice any performance issues.

In this case, I *did* have crap on my desktop that wasn't in Dropbox and wasn't yet backed up to the cloud. I just hooked up the drive and restored from File History. I literally lost nothing. All my desktop crap was restored in place. If you have an external drive that you always have hooked up but it's not really getting use, setup File History in just minutes.

Multiple Cloud-based Backups

I have a number of clouds in my backup rotation:

  • GitHub - I have github repos, both private and public for code.
  • DropBox - My primary cloud files backup
  • OneDrive for Business - My work cloud files backup
  • Synology - I love my Synology. It's a complete home NAS Server with massive storage, RAID, VPN, Docker, and so much more. A daily joy and a local cloud.
  • CrashPlan - I keep TBs up there and pay them happily for the service.

Related Links

Here's some additional reading on ways to back up your system. Please do also help non-technical relative back up their stuff as well. Every week I hear about someone working on their PhD thesis losing their whole life's work an instant. Backup is a system and it CAN be automatic.

What do you do for backup?


Sponsor: Many thanks to my friends at Stackify for sponsoring the feed this week! it’s what being a developer is all about so do it the best you can. That’s why Stackify built Prefix. No .NET profiler is easier or more powerful. You’re 2 clicks and $0 away, so build on! Prefix.io.

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.