Unable to run custom MSBuild targets before/after MGCB task

Hello there!:blush:

I just updated my whole code base to the new prerealease version and now I try to implement a custom build process with MSBuild (though I am fairly new with the “targets” stuff :sweat_smile:)

According to this part of the MGCB documentation, I can use BeforeTargets="BuildContent" and AfterTargets="BuildContent" to do things before or after the MGCB process runs.

So here is what I tried in my .csproj :

<Project Sdk="Microsoft.NET.Sdk">


    <PackageReference Include="MonoGame.Content.Builder.Task" Version="" />

  <Target Name="MyBeforeTarget" BeforeTargets="BuildContent">
    <Message Text="MyBeforeTarget Ran"/>
  <Target Name="MyAfterTarget" AfterTargets="BuildContent">
    <Message Text="MyAfterTarget Ran"/>
  <Target Name="IncludeContent" BeforeTargets="PrepareForBuild">
    <Message Text="IncludeContent Ran"/>


Unfortunately, none of these targets seem to be called as long as MonoGame.Content.Builder.Task is in the project. Only the MGCB task runs during the build and I don’t see any other message in the Build Output. Am I missing something?

Ah, the target names got changed: https://github.com/MonoGame/MonoGame/blob/develop/Tools/MonoGame.Content.Builder.Task/MonoGame.Content.Builder.Task.targets#L13

1 Like