Fixing error MSB4036: The “GetReferenceNearestTargetFrameworkTask” task was not found

When you build a project with MSBUILD Tools 2017 and getting “MSB4036: The “GetReferenceNearestTargetFrameworkTask” task was not found” error, you probably need to update your MSBUILD Tools components.

Download the latest version of MSBUILD tools from https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2017, run it, choose Modify and then select “Web development build tools” and “.NET Core build tools”.

If you are getting error CS8107: Feature ‘default literal’ is not available in C# 7.0. Please use language version 7.1 or greater.

or

error CS8107: Feature ‘leading digit separator’ is not available in C# 7.0. Please use language version 7.2 or greater.

You need to add <LangVersion>7.2</LangVersion> to your project file(s). Unless you specifically set up your project, Visual Studio 2017 uses the “C# latest major version (default)” option for C# language, which means you can use only up to C# 7.0:

You can either select C# 7.2 explicitly, or by adding <LangVersion>7.2</LangVersion> to .csproj file manually.

Note that C# 7.2 is not supported with the vanilla version of Visual Studio 2017. When it was released, Visual Studio 2017 only supports C# 7.0. Supports for C# 7.1, and later, 7.2, were introduced in later updates: 15.3 and 15.4, respectively. At this time of this update, 15.6.1 is available and I personally recommend to upgrade to latest version possible.

Make sure to add it to both debug and release configuration. It’s likely that you will run your server builds on release.

Upgrading to TeamCity 9.x: the JRE headaches

Today I updated our TeamCity server from 8.15 to 9.17. We need to support C# 6.0 so it’s an essential move. TeamCity 10 is still EAP and we would wait a couple of months after it comes out to make sure all the plugins are supported.

The installation was a breeze – the installer detected there was a previous version and offered to uninstall it. All good. Until there was a browser window opened so I can continue the configuration, but http://localhost/ only returned time out.

When I opened the Service Management (services.msc), it looked like the service was not running. I tried to start it, but then it stopped immediately. Events viewer was not exactly helpful, it gave a very obscure information:

The description for Event ID 404 from source TeamCity (see below) cannot be found. Either the component that raises this event is not installed on your local computer or the installation is corrupted. You can install or repair the component on the local computer.

If the event originated on another computer, the display information had to be saved with the event.

The following information was included with the event:

===============================================================
TeamCity JetBrains JetService v1.1.755.777
c:\TeamCity\bin\TeamCityService.exe
Service process exited without service stop request
===============================================================
Continue reading “Upgrading to TeamCity 9.x: the JRE headaches”

C# 6.0/Visual Studio 2015 on TeamCity

At first you will have to update to TeamCity 9.x (9.1.7 at the time of this post) to support Visual Studio 2015 compilation.

After upgrading (with some hassles, of course, but you’ll figure out), you’ll have TeamCity 9.x up and running. Now the time for some configuration. Change your compiler in build definition to Visual Studio 2015 and you are ready to go!

Change the Visual Studio to 2015

Change the Visual Studio to 2015

Not so fast. You will soon notice that most (if not all) of your build agents are not unusable.

MSBuildTools14.0_x86_Path does not exists
MSBuildTools14.0_x86_Path does not exists

Solution? Download and install Microsoft Build Tools 2015 from

https://www.microsoft.com/en-us/download/details.aspx?id=48159

Continue reading “C# 6.0/Visual Studio 2015 on TeamCity”