MSBuildUserExtensionsPath
My build depends on a third-party MSBuild extension and I don't have permissions to setup it up directly in the agent.
I'm running my build using Cake, that is started by a PowerShell build step, so I don't use the MSBuild build step.
To workaround this issue I did the following:
1. Added to my repository a file .\tools\MsBuild\14.0\Microsoft.Common.Targets\ImportAfter\Success.targets containing:
<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="SuccessMessage" BeforeTargets="Build">
<Message Importance="High" Text="*** SUCCESS ***" />
</Target>
</Project>
3. Added a new parameter to TeamCity build settings:
Name: env.MSBuildUserExtensionsPath
Kind: Environment variable (env.)
Value: %teamcity.build.checkoutDir%\tools\MSBuild
4. Built but the message *** SUCCESS *** does not appear in the logs although MSBuild logs what seems to be the correct MSBuildUserExtensionsPath value.
The .targets in this folder are supposed to be imported by Microsoft.Common.targets.
It works on my machine using Visual Studio and adding the Success.targets file to C:\Users\***\AppData\Local\Microsoft\MSBuild\14.0\Microsoft.Common.Targets\ImportAfter where *** is my login.
Am I missing something? Thanks in advance.
Please sign in to leave a comment.
Hello Antao,
It does not really look like a TeamCity-related issue so far.
Could you please try to make your build work locally with your custom MSBuildUserExtensionsPath enviroment variable on a system similar to an agent and under an account the agent is running? When you manage to make it - then is it exactly what TeamCity does.
Do you need MSBuildExtensionsPath defined along with MSBuildUserExtensionsPath?
Antao,
You can also make sure that you pass your TeamCity build %env.*% parameter from Powershell into Cake and from Cake to MSBuild by MSBuildSettings.WithProperty(string, string[]).
One more idea can be to change variable's kind to Configuration Parameter (%config.%).