How to run MSBuildBootstrap from command line


I want to integrate StyleCop in TeamCity.

I've created an MSBuild file and added TC build step as described in this example.

Everything works fine and results are the same as in example, but the problem is, that I don't use regular TC build steps for build.

Instead of them I use FAKE library, where I already have all my other build steps defined.

So I would like to run the same MSBuild build step using command line.

When I run regular TC MSBuild build step, in build log I can find the following line:

Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\TeamCity\buildAgent\work\7f1b9a681c01622c "/msbuildPath:C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe"

I've tried to run the same line from my build script and I've got the following error:

Failed to start MSBuild.exe. 'buildfile' parameter should be defined.

Then I added a project file name and target parameter:

C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe StyleCop.proj /target:RunStyleCop /workdir:C:\TeamCity\buildAgent\work\7f1b9a681c01622c /msbuildPath:C:\Program Files (x86)\MSBuild\12.0\bin\MSBuild.exe

And got the following error:

ERROR JetBrains.TeamCity.Utils.CommandLineParser - Unexpected key. All keys should starts from '/'
[00:22:52][Step 3/3] JetBrains.TeamCity.Utils.CommandLineParseException: Unexpected key. All keys should starts from '/'
[00:22:52][Step 3/3]    at JetBrains.TeamCity.Utils.CommandLineParser.ParseParametrs(String[] args) in c:\BuildAgent\work\4cfd56b397a82803\src\Utils\src\CommandLineParser.cs:line 70
[00:22:52][Step 3/3]    at JetBrains.TeamCity.Utils.CommandLineParser..ctor(String[] commandLine) in c:\BuildAgent\work\4cfd56b397a82803\src\Utils\src\CommandLineParser.cs:line 26
[00:22:52][Step 3/3] Failed to parse run arguments. Unexpected key. All keys should starts from '/' in StyleCop.proj /target:RunStyleCop /workdir:C:\TeamCity\buildAgent\work\7f1b9a681c01622c /msbuildPath:C:\Program Files "(x86)\MSBuild\12.0\bin\MSBuild.exe"

Then I've managed to launch build using MSBuild.exe instead of MsBuildBootstrap.exe, but got error:

C:\TeamCity\buildAgent\work\7f1b9a681c01622c\StyleCop.proj(25,9): error MSB4036: The "TeamCitySetStatus" task was not found.

So I guess MSBuildBootstrap.exe runs MSBuild.exe and somehow makes it to support service tasks... Ideally I would like to use MSBuildBootstrap.exe instead of MSBuild.exe.

Is it possible to run MSBuildBootstrap.exe from command line? If so, could you provide an example how to do it?

Thank you,

Comment actions Permalink

Hi, Andrew

Short unswer is - no, it is not possible and not expected to run MSBuildBootstrap.exe outside of teamcity agent process since MSBuildBootstrap.exe resolves some of its parameters using teamcity-provided environment variables.
Next, in order to avoid "The "TeamCitySetStatus" task was not found" error please use a workaround described here.

Comment actions Permalink

What about recreating an msbuildbootstrap command using msbuild? It looks like msbuildbootstrap is just running msbuild. Unfortunately, I can't tell from the TeamCity logs what parameters it is passing to msbuild, so I can't recreate the msbuild command. Is there any documentation for msbuildbootstrap? 

My logs are as follows: 

[Step 1/3] Starting: D:\BuildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:D:\BuildAgent\work\e8f57dfa2eca8e8c /msbuildPath:C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe

[14:10:12][Step 1/3] in directory: D:\BuildAgent\work\e8f57dfa2eca8e8c
[14:10:14][Step 1/3] depot\Build\Scripts\ Build target: PublishRelease (1m:10s)
[14:10:14][depot\Build\Scripts\] PublishRelease (1m:10s)
[14:10:14][PublishRelease] CreateCustomBuildLabelTask (1s)
[14:10:15][CreateCustomBuildLabelTask] Creating custom build label from TeamCity build number 7375.
[14:10:15][CreateCustomBuildLabelTask] Generated build label is 2016.02.01.ReleaseCandidate
[14:10:15][PublishRelease] CopyBuildArtifactsTask (5s)


Please sign in to leave a comment.