7
votes

We use TeamCity (9.0.1) as our build server, but having recently upgraded our ASP.NET MVC solution to use VS2015 and C#6 syntax, I now get the following error message on our build server:

Can not start build runner

and more specifically:

C:\TeamCity\buildAgent\work\86ee61c6c333dc3d\MyApplication\MyApplication.csproj.metaproj : error MSB4025: The project file could not be loaded. Could not find file 'C:\TeamCity\buildAgent\work\86ee61c6c333dc3d\MyApplication\MyApplication.csproj.metaproj'.

I followed the advice in several different posts (though these are mainly TFS focused rather than TeamCity and don't refer to the missing ".metaproj" file directly):

So, in summary, I have made the following changes to my Build Server:

  1. Installed Visual Studio 2015 Update 2
  2. Changed the PowerShell script that performs the build

from:

msbuild '..\MyApplication.sln' /t:Build /p:Configuration=Release /p:RunCodeAnalysis=Always /p:VisualStudioVersion=12.0

To:

msbuild '..\MyApplication.sln' /t:Build /tv:14.0 /p:GenerateBuildInfoConfigFile=false /p:Configuration=Release /p:RunCodeAnalysis=Always /p:VisualStudioVersion=14.0

Note:

  • If I log onto the Build Server and attempt to compile the solution using VisualStudio 2015 then this works fine.

  • In one of the posts mentioned above, it discussed upgrading from "TfvsTemplate.11.1.xaml" to "TfvsTemplate.12.xaml". But as far as I can't tell, I don't use or reference this. Maybe I'm much mistaken here, in which case an idiot's guide of what to do next would be gratefully received.

2
Seems like the same issue: youtrack.jetbrains.com/issue/TW-44075. Could you check whether the issue is reproduced on TeamCity 9.1.6?Alina Mishina
Is the MsBuild path updated to use the one under `C:\Program Files (x86)\MSBuild\14.0\Bin`Kai Zhao
Hi Kai. The MSBuild Path Environment Variable was still pointing to \12.0\ so I updated that to 14.0 and rebooted the server. The TeamCity agent now reports the path to be \14.0\ but alas building still reports that "The project file could not be loaded. Could not find file 'C:\TeamCity\buildAgent\work\86ee61c6c333dc3d\MyApplication\MyApplication.csproj.metaproj' "DrGriff
Alina: Certainly the release notes regarding 9.1.x suggest that it supports the VS 2015 and .NET enhancements. I therefore installed the latest version of TeamCity on a separate machine (so as to not affect our Build Server) but that is now reporting the same problem.DrGriff
@DrGriff If you still having probblem. I would do what Boyan suggested first, clean up the work folder if that did not happen automatically for every build. Then I would build the solution file by using the 14.0 msbuild in command line on the machine. If build failed, I'd troubleshoot the build dependency, if succeed, I'd ask teamcity to run a script to execute the msbuild instead of using any existing module/add-on. That should isolate the problem.Kai Zhao

2 Answers

11
votes

Finally....we fixed it.

I had to take the following steps on the Build Server:

  1. Installed VS2015 Update 2
  2. Edit the Environment Variable "PATH" to change one setting from C:\Program Files (x86)\MSBuild\12.0\Bin\; to C:\Program Files (x86)\MSBuild\14.0\Bin\;
  3. Since we use TeamCity to fire off a PowerShell script that in turn fires off the MSBuild. I updated the PowerShell module PSAKE from 4.2 to 4.6 (but this might not have been necessary)
  4. Created a new Environment Variable "MSBuildEmitSolution" and gave that a value of "1"
  5. Copied the file "Microsoft.Build.Tasks.v12.0.dll" from "C:\Program Files (x86)\MSBuild\12.0\Bin\amd64" to "C:\Program Files (x86)\MSBuild\14.0\Bin\amd64". No idea why this was reported as an error in our BUILD log because it's not an AMD machine...
  6. Using NUGET, had to add the package "Microsoft.Net.Compilers" to every C# project that used C#6 syntax (basically, all of them)

Not all of the above steps may be strictly necessary, but I would suggest that certainly steps 1. and 5. were definitely required.

HTH

Griff

0
votes

I've had this issue before and I think you can resolve it by logging into the TeamCity directory and deleting all the files in the working directory. Or doing a "clean" of the working directory before you do a checkout. I recommend just deleting the files manually. Also with TeamCity 9.1.6, you don't need the full Visual Studio installed on the server, just the Microsoft Build Tools 2015 (https://www.microsoft.com/en-us/download/details.aspx?id=48159), and then use the "MSBuild" runner type or the "Visual Studio (sln)" runner type.