The best solution I have found so far is adding
<ItemGroup>
<ProjectReference Include="..\CustomBuildStep\CustomBuildStep.csproj" PrivateAssets="all" ReferenceOutputAssembly="false" />
</ItemGroup>
to FinalOutput.csproj
, and
find PublishFolder -name "CustomBuildStep*" -print0 | xargs -0 rm
to the build script. It seems like it ought to be possible to put the latter into a post-build or post-publish step of FinalOutput.csproj
, but I wasn't able to figure that out.