Three issues (with solutions) when upgrading to Visual Studio 2017

In the last 2 weeks I’ve upgraded two (large) C# / ASP.NET solutions from Visual Studio 2015 to Visual Studio 2017. Good news? By and large things ‘just’ work. But there were three things that required attention:

  1. Issue: My project used PowerShell projects from “PowerShell Tools for Visual Studio 2015“. This VS2015 extension did not automatically get activated for VS2017.

    1. Download and reinstall the extension. The installer recognized that VS2017 was now installed and enabled the extension for VS2017.
  2. Issue: The projects were both using the Microsoft Unit Test framework and the unit test runner would run without issue in VS2017, but Live Unit Testing would not work.

    1. In the Unit Test project(s) remove the reference to: Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
    2. Use nuget to add MSTest.TestAdapter and MS.TestFramework to the unit test project:
  3. Issue: My Team Services CI build failed after I started using C#7 syntax in my code.
    Solution: Install Visual Studio 2017 on the build server and change the build definition to use Visual Studio 2017 for building the solutions.
    Alas, this will not (yet) work if you’re using a Hosted Agent. So be sure to be using a build agent that runs on a machine where Visual Studio 2017 is installed.

Useful to know:

  • For a short time some team members were working with VS2015 and some with VS2017. No problem as long as you’re not using C#7 syntax just yet 🙂
  • Play around with including/excluding tests from Live Unit Testing, for larger solutions the performance hit of having all the tests being run all the time seems prohibitive.

TDD – Path to code Zen

tdd-red-refactor-greenTest Driven Development has many advantages, but there is one that I discovered the other day: it helps create order in the chaos that can be your own brain and it helps keep track of the progress you’ve made in implementing a complex algorithm.

The story
I was working a complicated algorithm. Doing well, I had about 30 different scenarios that needed to be supported, all organized in my brain. Coding, coding, coding… This is probably a 6-8 hour job and I’m about half way done. Phone rings, I get drawn into a DevOps issue. Done, time to get back into code Zen, not easy, but almost back in, phone rings again.
This happens two more times, and then I’ve lost it. Unable to get back into the code Zen. The scenarios just don’t want to line back up in my brain. After 30 minutes of trying, of attempting to code, no real luck. I give up, knowing that if I start fresh in the morning I can get back into Zen… until of course the first call comes in.

Next morning I decide I need to apply TDD. Build my unit tests, take the implementation one scenario at a time. And it is working! The phone still rings, but in order to achieve code Zen I only need to get back into the one scenario I was working on when the phone rang. Much easier than organizing my brain around the 30+ scenarios that I had to keep track of before.

Win for TDD.

Happy coding.