Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to write inline code in <Target Name="AfterBuild"> in VisualStudio.csproj

if $(ConfigurationName) doesn't work in <AfterBuild>

<Target Name="AfterBuild">
if $(ConfigurationName) == Release (
    <Exec Command="grunt karma:unit --no-color &gt; grunt-karma-output.txt" IgnoreExitCode="true" />
    <Exec Command="type grunt-karma-output.txt" CustomErrorRegularExpression=".*mPhantomJS.*FAILED" IgnoreExitCode="false" />
)
</Target Name="AfterBuild">

if $(ConfigurationName) WORKS in <PostBuildEvent>

<PostBuildEvent>
if $(ConfigurationName) == Release (
    <Exec Command="grunt karma:unit --no-color &gt; grunt-karma-output.txt" IgnoreExitCode="true" />
    <Exec Command="type grunt-karma-output.txt" CustomErrorRegularExpression=".*mPhantomJS.*FAILED" IgnoreExitCode="false" />
)
</PostBuildEvent>

Could anyone suggest how to check if the build is in release mode in AfterBuild?

like image 440
Gururaj Avatar asked Feb 15 '23 03:02

Gururaj


1 Answers

Use a Condition on the target:

<Target Name="AfterBuild" Condition="$(Configuration)==Release">
  <Exec Command="echo AfterBuild"/>
</Target>

Btw this also works the same way for the PostBuildEvent (and the code you posted definitely does not work).

<PropertyGroup Condition="$(Configuration)==Release">
  <PostBuildEvent>echo PostBuild</PostBuildEvent>
</PropertyGroup>
like image 125
stijn Avatar answered Mar 10 '23 11:03

stijn