Share via


Running batch file before and after Visual Studio 2010 Ultimate compile

Question

Tuesday, July 31, 2012 7:32 PM

I have recently been doing a lot of development work with Windows services. I have created batch files to stop a service, unload a service, or unload/load new/restart a service. Ideally, I would like to automate the shut down services, rebuild solution, and then restart the newly built services as part of the build process.

Is there a way of integrating these batch processes in the Visual Studio compile/build flow?

Thanks, Warren

Warren

All replies (4)

Thursday, February 7, 2013 2:52 PM ✅Answered

I am adding the appropriate link to the information that addresses this issue in this forum, since almost 1000 visitors have viewed the item.

http://msdn.microsoft.com/en-us/library/ke5z92ks(v=VS.80).aspx

The basic process defined at the link is as follows:

  1. In Solution Explorer, select the project for which you want to specify the build event.

  2. On the Project menu, click Properties.

  3. Select the Build Events tab.

  4. In the Pre-build event command line box, specify the syntax of the build event.

    Note

    Pre-build events do not run if the project is up to date and no build is triggered.

  5. In the Post-build event command line box, specify the syntax of the build event.

    Note

    Add a <tt xmlns:asp="http://msdn2.microsoft.com/asp">call</tt> statement before all post-build commands that run .bat files. For example, <tt xmlns:asp="http://msdn2.microsoft.com/asp">call C:\MyFile.bat</tt> or <tt xmlns:asp="http://msdn2.microsoft.com/asp">call C:\MyFile.bat call C:\MyFile2.bat</tt>.

  6. In the Run the post-build event box, specify under what conditions to run the post-build event.

    Note

    To add lengthy syntax, or to select any build macros from the Pre-build Event/Post-build Event Command Line Dialog Box, click the Ellipsis button () to display an edit box.

    The build event syntax can include any command that is valid at the command line or in a .bat file. The name of a batch file should be preceded by <tt xmlns:asp="http://msdn2.microsoft.com/asp">call</tt> to ensure that all subsequent commands are executed.

Warren


Wednesday, August 1, 2012 8:22 AM

Hi Warren,

It seems your issue is more related to develop forum.

What's your project type and programming language?

I'm trying to redirect you to the right forum.

Regards,

Barry Wang [MSFT]
MSDN Community Support | Feedback to us


Wednesday, August 1, 2012 9:11 AM

Barry,

I am developing in C# now, but also do C++ work as necessary. If you mean Visual Studio project types, I am currently using .NET 4.0 for Windows Services and WCF projects, and I am using Silverlight 5 for the client. I use a variety of library projects. 

What I am trying to find out is whether or not there is an easy way of injecting batch files as part of the VS build process. Can I do this through the GUI or is there a batch mode for VS that I can use? I am looking for some 'how to' tips, if any are available. The build process could contain any number of Visual Studio projects and various technologies. I looked at many of the other forum choices, but did not see anything that applied other than this forum. My question in very general in nature.

Thanks...

Warren


Monday, August 6, 2012 5:59 AM

Hi Warren,

Sorry for the late track.

You may have to ask your questions here:

http://social.msdn.microsoft.com/Forums/en-US/wcf/threads?page=2

If the project is written in C#, please open a new thread here:

http://social.msdn.microsoft.com/Forums/en/category/visualcsharp

If the project is written in C++, please open a new threa here:

http://social.msdn.microsoft.com/Forums/da-dk/category/visualc

Best regards,

Barry Wang [MSFT]
MSDN Community Support | Feedback to us