0

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?

Lex Li
  • 60,503
  • 9
  • 116
  • 147
Ross Presser
  • 6,027
  • 1
  • 34
  • 66
  • Manually copying the contents of the second folder to the first folder did make the build work (or at least, get past that error; I have other errors to resolve). – Ross Presser Oct 31 '19 at 17:46
  • Based on posts like https://teamcity-support.jetbrains.com/hc/en-us/community/posts/115000717470-Windows-agent-cannot-find-VS-2017-and-MSBuild-2017-with-latest-15-4-4-update it is strictly a TeamCity issue, which you didn't use the right tag, and also investigated on the wrong direction. – Lex Li Oct 31 '19 at 19:32
  • @LexLi you responded with a link to a post over a year old, about a different version of TeamCity. While your statement that the answer is contained in "posts like" the one you linked to may contain an actual answer to my problem, your actual link is thoroughly useless for me. "investigated on the wrong direction" is also devoid of any meaning. I do thank you for providing the right tag. – Ross Presser Nov 12 '19 at 21:27
  • You are still using VS2017, which is not new either. I used the linked post to show you that to dig the culprit you should focus on TeamCity agent configuration, especially how it detects MSBuild. 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, so when TeamCity prefers Professional the issue happened. To fix that you either force TeamCity to use Build Tools, or you add VB to your VS Pro installation. None of them is "easy fix" or registry hack. – Lex Li Nov 12 '19 at 23:15
  • @LexLi While I agree that VS2017 is not new, literally everything in your latest response **is** new -- to this discussion. None of it was visible in your previous message or in the link, and I thank you for taking the time to provide this information. If you promote that comment to an answer then I will accept it. – Ross Presser Nov 14 '19 at 18:13

1 Answers1

1

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

Lex Li
  • 60,503
  • 9
  • 116
  • 147
  • Thank you! With this hint, I was able to go back to the working agents, extract their install config, and use it to fix the VS Pro installation on the new agents. All my build configs that work on the old agent now work on the new ones. – Ross Presser Nov 22 '19 at 18:37