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 whi
A workaround for this problem is to customize the MSBuild process to set the path at which the "Target Framework Moniker Assembly Attributes" file (the proper name for the file mentioned in the question) will be created.
The TargetFrameworkMonikerAssemblyAttributesPath
property is defined in Microsoft.Common.targets determines where the file should be created. By overriding this property, the location can be changed to use a different location.
Here's a script that can be used to achieve a suitable replacement:
$(PrepareForBuildDependsOn);
_SetTargetFrameworkMonikerAssemblyAttributesPath
$([MSBuild]::GetRegistryValue("HKEY_CURRENT_USER\Environment", "TMP"))
$([MSBuild]::GetRegistryValue("HKEY_CURRENT_USER\Environment", "TEMP"))
$(USERPROFILE)
$([System.IO.Path]::Combine('$(WINDIR)', 'Temp'))
$([System.IO.Path]::Combine('$(TargetFrameworkMonikerAssemblyAttributesDir)','$(TargetFrameworkMoniker).AssemblyAttributes$(DefaultLanguageSourceExtension)'))
The target is only executed when TEAMCITY_VERSION
is specified as a property, which should be when the build is being executed by the TeamCity agent.
NOTE: The child elements of the PropertyGroup
should each be on a single line. They have been spread over multiple lines to increase readability here, but the additional line-breaks cause the script to fail.
When the target runs, it tries to build a suitable path based on the user's environment variables as defined in the registry, first looking for TMP
and TEMP
, before falling back to the user's profile folder and finally the C:\Windows\Temp
directory. This matches the order documented by System.Path.GetTempPath(), and should result in behaviour matching MSBuild execution outside of TeamCity.
This should be saved as a .targets file somewhere on the system and imported to the .csproj file of projects being built by the TeamCity server, using an
element. I added the script under my MSBuild extensions directory (C:\Program Files\MSBuild\
) and referenced it by adding the following import element:
The location/ordering of Import elements doesn't matter, but I suggest including it after the
which should appear in every .csproj file.