views:

639

answers:

1

For normal (say Windows Forms) C# applications, to execute commands after a successful build I would use the Build Events->Post-build event command line in Project Properties.

I have a Web Site project which I "Publish", using the "Publish..." command in the context menu in the solution explorer.

Is there a way to run commands after the successful publish and if so how is it done? (eg a Post-Publish event command line field)

Visual Studio 2008, ASP .Net Web site project, C#.

+3  A: 

Update: Since Publish Web does not apply to folder-based web site projects, this answer assumes you are asking about a Web Application project.

You can't do this from inside the VS IDE. However, you can edit your project file in Notepad or your favorite XML editor and add a new target at the end of the file called AfterPublish.

You might want to read a bit more on MSBuild if you are not sure what you can do in this target.

You can find more details on extending the build process in VS at MSDN - HowTo: Extend the Visual Studio Build Process.

Franci Penov
Thanks, I feared that it would not be possible inside the IDE. This is a fine solution as our CI uses msbuild scripts. I was hoping we could do it inside Visual studio as well. What I might do is create a new msbuild script, then create an "External Tools" command to run that build script instead of doing a visual studio "publish." Would prefer not to modify the proj file if possible.Thanks for your help and quick response!
Russell
I voted answer down because I don't understand how this can be an accepted answer. A Web Site does not have a project file. Please help me and others understand by clarifying the answer or providing a comment of why this answer was accepted.
AMissico
It's just mixed terminology. You are right - folder based web site projects don't have a project file. However, there's also no Publish command for such projest. Web application projects on the other hand do have a project file and Publish Web command applies to them. My assumption was that the question refers to a web app vs. web site. Since my answer was accepted, I would venture to guess that my assumption was correct. That does not excused me from using the right terminology, of course.
Franci Penov
Thank you for clarifying. I removed down vote.
AMissico