Andrii Plakhotnyi
Andrii Plakhotnyi

Reputation: 148

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.

Upvotes: 1

Views: 1144

Answers (2)

Sayed Ibrahim Hashimi
Sayed Ibrahim Hashimi

Reputation: 44312

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>

Upvotes: 1

Martin Ullrich
Martin Ullrich

Reputation: 100543

What you probably want is:

<PropertyGroup>
  <PostBuildEvent>echo Hello</PostBuildEvent>
</PropertyGroup>

Upvotes: 0

Related Questions