What Was I Thinking?

Follies & Foils of .NET Development

  Home  |   Contact  |   Syndication    |   Login
  74 Posts | 0 Stories | 191 Comments | 0 Trackbacks

News

Archives

Post Categories

Check These Out

Gurus

In Visual Studio (2008) Web Site Projects do not support pre/post build events.  Web applications do, but web sites do not.

 

This doesn’t mean you can’t have pre/post build events however.  You just have to be a little creative.

 

In my scenario, I needed a pre-build event to fire. 

1. I added a new class library project to my solution and configured its post build event to execute the pre-build event I wanted. 

2. I added a project dependency on the Web Site of the new class library.

Right click the solution explorer on the solution node.

Select Project Dependencies.

Select the web site in the project list dropdown at the top of the dialog.

Check the new class library project on the list of available projects.

Close the dialog.

Now when my web site builds, it builds my new class library, which in turn executes its post-build event.  The result is custom logic executing before my web site is built.  SUCCESS!

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati
posted on Saturday, January 30, 2010 4:01 PM

Feedback

# re: How to get Pre-Build Event support for Web Site Projects 5/10/2011 7:27 AM James
I am always interested in internet security tutorials. My opinion is that your solution here could be modified to actually offer an extra degree of security to certain web applications.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: