When compiling a .NET Core 3.1 console application, I want to execute a command only on Rebuild (not Build). I can successfully use the "PreBuild" event, but that executes on both Build & Rebuild. Here is an example of what I am trying to achieve:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<Target Name="BeforeRebuild" BeforeTargets="Rebuild">
<Exec Command="foo" />
</Target>
</Project>
As written, the command never executes. I believe the problem is that "Rebuild" is not a valid target.