Visual Studio has a handy feature for running commands before or after builds. This can be used to automate part of your development process, such as withdrawing dependencies during the development phase or sending construction items to development environments.
Set pre-built and post-built commands
Right-click the project from Visual Studio and click “Properties.”;
Then, under “Build events”, you will find the controls for setting the commands that run before and after build. This is a standard CMD prompt, so if you want to run Powershell or Bash commands, you must start Powershell and WSL, respectively, and send it in a script.
Note that this command runs in the directory for building items. This may vary depending on your configuration, but it is generally
project/bin/ProfileName/. You must add relative references to run commands in higher subdirectories.
At the bottom you can set some controls for the post-build command. If you do not want to do anything with a failed build, set it to “On Successful Build”, and if you do not want to send duplicate builds, set this to “When build build updates.”
If you click on “Edit mail building”, you will see a window with all the variables you can send to your script.