Technology

#How to Run a Command Before or After a Build in Visual Studio – CloudSavvy IT

“#How to Run a Command Before or After a Build in Visual Studio – CloudSavvy IT”

Visual Studio.

Visual Studio has a handy feature for running commands before or after builds. This can be used to automate some of your development process, such as pulling in dependencies during the prebuild phase, or sending build artifacts to development environments.

Setting Up Prebuild and Post-build Commands

From Visual Studio, right click on the project, and click “Properties.”

 Visual Studio, right-click project, click "Properties."

Then, under “Build Events,” you’ll find the controls for setting the commands that run before and after the build. This is a default CMD prompt, so if you want to execute Powershell or Bash commands, you’ll need to launch Powershell or WSL respectively, and pass it in a script.

Note that this command is executed in the directory of the build artifacts. This can vary depending on your configuration, but it’s generally project/bin/ProfileName/. You’ll need to add relative references to run commands at higher subdirectories.

Running prebuild and postbuild events.

At the bottom, you can set some controls for the post-build command. If you don’t want to do anything with a failed build, set this to “On Successful Build,” and if you don’t want to send duplicate builds, set this to “When the build updates.”

If you click “Edit Post-Build,” you’ll see a window listing all the variables you can pass to your script.

 "Edit Post-Build" variables.

If you liked the article, do not forget to share it with your friends. Follow us on Google News too, click on the star and choose us from your favorites.

For forums sites go to Forum.BuradaBiliyorum.Com

If you want to read more like this article, you can visit our Technology category.

Source

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button
Close

Please allow ads on our site

Please consider supporting us by disabling your ad blocker!