Bobson
Bobson

Reputation: 13716

TeamCity vs MSBuild command line

I have a .csproj file which behaves differently when I build it in TeamCity compared to when I build it via the msbuild.exe executable. If I knew why, I could try and fix it, but I've run out of ideas.

Command line: (formatted for readability)

"C:\Program Files (x86)\MSBuild\12.0\bin\msbuild.exe" 
    Web\MyProject\MyProject.csproj 
    /p:Configuration=Dev;PublishProfile=Dev.pubxml;OutputPath="bin\\";DeployOnBuild=true 
    /t:Package

TeamCity build step: (as it shows up in the metarunner, although I get the same behavior when treating it as a regular build step, and I've removed the dotNetCoverage parameters)

  <runner name="Package Service" type="MSBuild">
    <parameters>
      <param name="build-file-path" value="Web/MyProject/MyProject.csproj" />
      <param name="msbuild_version" value="12.0" />
      <param name="run-platform" value="x86" />
      <param name="msbuild.prop.Configuration" value="Dev" />
      <param name="msbuild.prop.DeployOnBuild" value="true" />
      <param name="msbuild.prop.PublishProfile" value="Dev.pubxml" />
      <param name="msbuild.prop.OutputPath" value="bin\\" />
      <param name="msbuild.prop.Platform" value="AnyCPU" />
      <param name="targets" value="Package" />
      <param name="teamcity.step.mode" value="default" />
      <param name="toolsVersion" value="12.0" />
    </parameters>
  </runner>

What's the difference between these?

The behavior I'm seeing is that an assembly on which MyProject.csproj depends (but which doesn't have the "Dev" build configuration) will build just fine with msbuild, but will fail with TeamCity (version 9.1.1).

Specifically, both methods will start with the task ValidateGlobalPackageSetting, but TeamCity then goes on to ResolveProjectReferences while msbuild goes on to CollectFilesFromIntermediateAssembly.


Having created diagnostic logs from msbuild for both methods, I found my problem, but I'm not sure how to fix it.

The teamcity log has _DeployOnBuild = False, but my msbuild log has _DeployOnBuild = true. That would definitely explain the differences in behavior I'm seeing, but I don't have a clue why TeamCity is ignoring the msbuild.prop.DeployOnBuild property.

Upvotes: 3

Views: 1519

Answers (1)

Bobson
Bobson

Reputation: 13716

I asked this on the offical Jetbrains tracking system and got an answer.

Apparently, TeamCity doesn't support arbitrary msbuild.prop.* arguments the way I expected it to. The only two that it supports are Configuration and Platform. For the rest, I needed to add this line:

<param name="runnerArgs" value="/p:DeployOnBuild=true;PublishProfile=%Configuration%.pubxml;OutputPath=&quot;bin\\&quot; />

Upvotes: 0

Related Questions