Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can not build app (.NET Framework 4.6.2) in TeamCity

I'm using TeamCity 9.1.3. We are using MSBuild Tools 15 to build our app. Our app was targeting 4.5.2 and everything went fine. Now we've changed the framework inside the app to 4.6.2. The developers are able to build their app locally by using Framework 4.6.2 in Visual Studio.

But on our TeamCity server the build is failing. It seems that TeamCity is still using the old framework. We did install the 4.6.2 Framework. We have MS BuildTools 15. Our MSBuild Toolsversion is 14 and runplatform x64. This is al the same for the applications which are still using 4.5.2 framework.

What do we have to change so our TeamCity Job for this app will use 4.6.2 (by using the same buildTools 15 as our other apps which are still using 4.5.2).

We don't see 4.6.2 inside the MSBuild version button inside our job configuration. We see BuildTools 15, BuildTools 13 and .NET Framework 4.5, 4.0, 3.5, ...

I also don't see the 4.6.2 Framework inside the Windows and Features of our Server (but it's installed on the host). We're working on Windows Server 2012 R2.

like image 754
DenCowboy Avatar asked Oct 29 '22 04:10

DenCowboy


1 Answers

This worked for me, so here's what you need to do.

Install MSBuildTools15.

Use NuGet for the following:

nuget install Microsoft.Net.Compilers
nuget install Microsoft.CodeAnalysis

Set project language to c# 6 (Properties | Build | Advanced Settings | Language version C# 6.0

Copy VS 14.0 settings from a good version (dev machine with Visual Studio installed) and place on target build server C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0*.*

Added as first step to your TeamCity Build

  • Runner Type: NuGet Installer
  • Step Name: Get Packages
  • Nuget.exe

Note: you won't see 4.6.2 inside the MSBuild version, but it'll compile just the same.

like image 107
Aeroradish Avatar answered Nov 12 '22 23:11

Aeroradish