Search code examples
.netvisual-studioazure-pipelinespre-build-event

How to resolve solution-level pre-build event macros when building the project on the build server?


I've specified a pre-build event

$(SolutionDir)Tools\ResxConverter.CLI.exe android $(SolutionDir)$(SolutionName).Core\Resources\ $(ProjectDir)Resources\

This works for me locally, but the build server is failing with the following:

*Undefined*Tools/ResxConverter.CLI.exe android *Undefined**Undefined*.Core/Resources/ /Users/MyUser/myAgent/_work/9/s/MyProjectName/Resources/

It seems the macros aren't resolving. Apparently this is because the build server builds each project individually, and the macros are only available at a solution level, but I'm not certain on that.

What do I need to do to resolve the paths to the pre-build exe on the build server?


Solution

  • It turns out the fix was to modify the PreBuildEvent to refer to the ProjectDir rather than the SolutionDir, e.g.

    <PreBuildEvent>$(ProjectDir)..\Tools\ResxConverter.CLI.exe ios $(ProjectDir)..\MyProject.Core\Resources\ $(ProjectDir)Resources\</PreBuildEvent>

    This resolved the variables relative the the project, rather than the solution.