'How to add a post build event in MSBuild for .Net 6.0 on Mac?
How do I need to edit a *.csproj
file to add a PostBuildEvent on Mac?
I am trying the following but it doesn't work:
<ItemDefinitionGroup>
<PostBuildEvent>
<Command>echo Hello</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
Then I invoke dotnet build -f net6.0-maccatalyst
and the event isn't called.
Solution 1:[1]
What you probably want is:
<PropertyGroup>
<PostBuildEvent>echo Hello</PostBuildEvent>
</PropertyGroup>
Solution 2:[2]
The PropertyGoup
approach as mentioned works, but you can also create a new target like the following if need to add more than just a simple message.
<Target Name="MyAfterBuild" AfterTargets="Build">
<Message Importance="high" Text="Hello from MyAfterBuild" />
</Target>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Martin Ullrich |
Solution 2 | Sayed Ibrahim Hashimi |