Conditional prebuild event always trigger on Mac

In many of my projects of one large solution (that builds a suite of Nuget packages) I want to run a small tool when I build for Release. This works fine on Windows but when I build on Mac, for "Debug", the tool gets run anyway (and fails).

This is the pre-build event:
if $(ConfigurationName) == Release dotnet <path to tool + args>

And this is the output from the failed build:

<name of project>.csproj(47, 5): [MSB3073] The command "if Debug == Release dotnet <path to tool + args>" exited with code 1.

Any hints would be appreciated

0
1 comment

Hello Jonas Rembratt,

Thank you for contacting Rider forum.

The possible reason for such behaviour is the fact, that the command mentioned in the event itself is designed for DOS and not for the MacOS. There is a thread in Visual Studio community, that has in its example change of command from: 

<Target Name="PostBuild" AfterTargets="PostBuildEvent">    <Exec Command="if "$(ConfigurationName)" == "Release" (obfuscar.console "$(ProjectDir)\obfuscar.xml" -s) exit /b 0" /> </Target>
To:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">     <Exec Condition="'$(ConfigurationName)' == 'Release'" Command="obfuscar.console "$(ProjectDir)\obfuscar.xml" -s" /><br></Target>

Could you please try tweaking up the condition in the same manner?

Thank you in advance! Looking forward to hearing from you soon.

0

Please sign in to leave a comment.