Ross Presser
Ross Presser

Reputation: 6255

MSBuild looking in wrong place for Microsoft.VisualBasic.Core.targets

I am setting up a new TeamCity build agent. Several build configurations that run perfectly well on the existing agent are failing on the new agent, with errors like this (whitespace added for clarity):

[22:14:32][someproject.vbproj] 
C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin\Microsoft.VisualBasic.CurrentVersion.targets(322, 5): 
error MSB4019: The imported project 
"C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\15.0\bin\Roslyn\Microsoft.VisualBasic.Core.targets" 
was not found. 
Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

Note the path on line three after "The imported project". The error is correct; the folder does exist but the file does not exist there. However the Microsoft.VisualBasic.Core.targets file does exist at a slightly different path

C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\Roslyn\Microsoft.VisualBasic.Core.targets

Is there an easy fix for this, perhaps a registry entry telling MSBuild where to look?

Upvotes: 0

Views: 644

Answers (1)

Lex Li
Lex Li

Reputation: 63123

Cause

  • On your machine, there are two copies of VS 2017 installed, Professional edition and the raw Build Tools.
  • You didn't install VB bits for Professional, while did that for Build Tools.
  • TeamCity prefers MSBuild from Professional edition.

Combine all above, the issue happened.

Fix

You should either force TeamCity to use MSBuild from Build Tools, or add VB to your VS Pro installation.

Reference

https://blog.lextudio.com/the-rough-history-of-msbuild-cc72a217fa98

Upvotes: 1

Related Questions