MSBuild Runner: Behaves different than when run from the command line

I have a simple MSBuild script for building VS 2010 solution files from MSBuild Tasks:

<?xml version="1.0" encoding="utf-8"?>
<!--
The Incremental property if present and with value "true" specifies that the build is incremental. Otherwise a rebuild occurs
/p:Incremental="true" or false
-->
<Project DefaultTargets="RebuildAll;BuildAll" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     <Target Name="RebuildAll" Condition="'$(Incremental)'== '' Or '$(Incremental)' == 'false'">
          <MSBuild ContinueOnError="true" Projects="myProjects.sln" Targets="Rebuild" Properties="Configuration=Debug"
                                   SkipNonexistentProjects="true" StopOnFirstFailure="false">
          </MSBuild>
          <MSBuild ContinueOnError="true" Projects="myProjects.sln" Targets="Rebuild" Properties="Configuration=Release"
                                   SkipNonexistentProjects="true" StopOnFirstFailure="false">
          </MSBuild>
     </Target>
     <Target Name="BuildAll" Condition="'$(Incremental)'== 'true'">
          <MSBuild ContinueOnError="true" Projects="myProjects.sln" Targets="Build" Properties="Configuration=Debug"
                                   SkipNonexistentProjects="true" StopOnFirstFailure="false">
          </MSBuild>
          <MSBuild ContinueOnError="true" Projects="myProjects.sln" Targets="Build" Properties="Configuration=Release"
                                   SkipNonexistentProjects="true" StopOnFirstFailure="false">
          </MSBuild>
     </Target>     
</Project>


The solution builds a series of libraries and an exe.
The script runs without error from the commandline:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe myMSBuildScript.xml

The script, when run by a TeamCity Build Configuration in a MSBuild runner step, fails due to a linker error: LINK error LNK1181: cannot open input file 'CoreLib.lib. It appear to be an out of build order issue.
The Build Agent is running on a different machine than the Server.
The MSBuild Version: Microsoft.NET Framework 4.0
MSBuild ToolsVersion: 4.0
Run Platform: x86

My expectation is the MSBuild runner and commandline should exhibit identical behavior. What is the correct way to run a script of this sort?

Please sign in to leave a comment.