Today, I came to know about AfterBuild target when I was trying to build a GitHub project. I had hard time figuring out a failing command which was getting fired after the build. I was not sure from where the command was getting fired because its post build event was empty.
This was the tag which I commented to get rid of the error:
<Target Name="AfterBuild" DependsOnTargets="_GetSignToolPath">
<Exec Command=""$(_SignToolPath)" sign /fd sha256 /sha1 $(SigningCertificateThumbprint) /t http://timestamp.verisign.com/scripts/timstamp.dll /v "$(TargetPath)"" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(MSBuildThisFileDirectory)..\Demo Website\Content" />
</Target>
To edit post build events we go to project properties of any C# project and then click on Build Events tab. Here we get the option to edit the post-build event:
So similarly is there any UI in Visual Studio to edit AfterBuild targets of a C# project? OR this can be edited only by modifying the project XML after unloading the project. I'm using Visual Studio 2019.

In short:
There isn't any other UI in VS to edit
AfterBuildtargets, it can only be edited in project XML.Analyzing:
To my knowledge, there is no more UI for
AfterBuildtarget in Visual Studio.Actually, the
AfterBuildtarget is an empty predefined target, it is the same with other targets such asBeforeBuild,CoreBuildand so on. You can find the detailed description here: Override predefined targets.The document mentioned:
So, normally, there is no UI to edit/modify the
AfterBuildtarget in VS, and if you need to use it, or more accurate, override it, you need to edit MSBuild codes in a project file(.xxproj file).Focus on your issue, you mentioned you were not sure from where the command was getting fired because its post build event was empty.
Oh, just stop and add some other words about post build event. Actually, though post build event runs after Build completed, post build event is set as
<PostBuildEvent> XXXXX</PostBuildEvent>in<PropertyGroup>XXXXX</PropertyGroup>, and it is not very related toAfterBuildtarget.But is it possible to consider other methods to find out where the command was getting fired, for example, to check the output information from VS’s output window?
Output window will give you as much information as you want for the building process, if you have set the MSBuild project build output verbosity to
DetailedorDiagnosticin Tools > Options > Projects and Solutions > Build And Run. You can even search and find the related targets/events which you want to see.Did a small test and here are some screenshots:
BTW, yes, it is not convenient, indeed, it will be better if it can be set/modified by using UI.