I'm setting up TeamCity (migrating from CruiseControl.NET) and I'm struggling to get it to perform incremental builds through MSBuild.
I've got a small .proj file which contains a basic build script to invoke a build of my solution with some parameters fed in from TeamCity. When I invoke the script manually, MSBuild's Incremental Build features kick in and skip the build entirely on subsequent runs.
When calling this script via Team City, the build log shows the output of a clean compile every time. I've observed the working directory during builds and can see the output from the previous build hasn't gone anywhere.
I also manually called the build script from that directory by remoting onto the server and running MSBuild from the command-prompt. Running it this way triggers the expected incremental builds after the first invocation.
Even when starting the build from the dashboard with no changes made, a complete rebuild occurs.
I can't pinpoint the cause, but something appears to be giving MSBuild the impression that it's getting new changes and causing it to perform a rebuild on every run. I can't see much in the TeamCity documentation that would explain this - my expectation is that if there are no changes in the source control system, it would not update the working folder.
Is TeamCity passing some parameter to the build process which triggers a rebuild? Can I view these parameters?
Having examined a detail MSBuild log (/v:d
command-line switch), the reason a complete rebuild is occurring is due to the file .NETFramework,Version=v4.0.AssemblyAttributes.cs
being updated in the <Agent>\temp\buildTmp
directory on every build.
This file is normally found at %TMP%\.NETFramework,Version=v4.0.AssemblyAttributes.cs
; TeamCity is changing the local temp directory environment variable to reference the agent's temp folder. Unfortunately, this file is created by the Microsoft.Common.targets
part of the build process when absent. Deletion of the "temp" file before every build causes it to be created every build and is dynamically referenced in the build of every project file.
I need to find a way to prevent this file from being re-created on every build.
Adjusting TargetFrameworkMonikerAssemblyAttributesPath works around this issue, as Paul Turner mentions. Rather than battle the High Magick in Microsoft's build system scripts, I added an environment variable to set TargetFrameworkMonikerAssemblyAttributesPath in TeamCity project parameters.
In TeamCity's project settings, I set env.TargetFrameworkMonikerAssemblyAttributesDir to %env.windir%\Temp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With