vincedjango
vincedjango

Reputation: 1046

Using different version of MSBUILD.exe between Dev and Jenkins machine

I have a C# project developed with VS2017.

The server on which Jenkins runs doesn't have VS installed. I have .NET 4.7 installed on the dev computer and the server.

This is what I get when I type msbuild.exe /version:

Microsoft (R) Build Engine version XXX(see below)

I assume that when I build a project in VS2017, it uses the MSBUILD.exe located in the MicrosoftVisualStudio folder.

I'm concerned now to build on the Jenkins machine with a different version of MSBUILD.exe? What would be the best approach? Copy the folder C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild to the Jenkins computer?

Upvotes: 3

Views: 5834

Answers (2)

vincedjango
vincedjango

Reputation: 1046

I was getting several errors using on the server this version of MSBUILD.exe: C:\Windows\Microsoft.NET\Framework\v4.0.30319: 4.7.2053.0

Here are the steps followed to builwithout error a VS2017 C# on Jenkins 2.60.2

  1. Copy C:...\MicrosoftVisualStudio\2017\Pro\MSBuild to my server
  2. In Jenkins/Global Tool Configuration, in the MSBUILD section

    • Name: msbuild.exe
    • Path to MSBuild: C:\MSBuild\15.0\Bin
    • Default parameters: -p:FrameworkPathOverride="C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.7"

If Default parameters is empty, I was getting errors, so it is important.

Upvotes: 0

Martin Ullrich
Martin Ullrich

Reputation: 100761

This depends on what MSBuild features you use.

The safe way to build projects developed in VS 2017 is to build using the installed VS version of MSBuild (15) from either a full VS installation or the Build Tools for Visual Studio 2017.

Even though the .NET Framework version of MSBulid will be able to build a lot of projects, it is limited to an older C# version, so you'd have to install the Microsoft.Net.Compilers NuGet package to replace the compiler. But VS 2017 introduces new MSBuild syntax features as well as build tasks which cannot be patched into the legacy version of MSBuild so its use is highly discouraged.

Upvotes: 0

Related Questions