I am using a "web site" in visual studio 2008, and i would like to add a post-build event which would append the build time to the web.config file. Is it possible?
-
Doesn't seem like it. Is there any specific reason to use a web site instead of a web application? – Mladen Mihajlovic Apr 06 '09 at 14:21
-
There's no reason for me not to use the application, a web site seemed like a good idea at a time, and i didn't know the difference between the two. – PBG Apr 06 '09 at 16:07
-
Take a look at my answer below. – Mr. TA Feb 27 '15 at 20:31
6 Answers
I'm afraid this isn't supported for web sites, you'll need to use a web application project.

- 8,469
- 1
- 26
- 37
-
Thanks, i'll review the differences, and see if there's a way to switch from a website to a project. – PBG Apr 06 '09 at 16:08
-
1OK, I've now removed the dead link. Since I wrote this 3 1/2 years ago it's no surprise the link has died, I suspect MSDN archived the VS2008 page when VS2012 launched. – Steve Nov 08 '12 at 09:29
-
1Links for those who end up on the page (it's for VS2010 but helpful understanding WSP vs WAP): [Web Application Projects versus Web Site Projects](http://msdn.microsoft.com/en-us/library/dd547590(v=vs.100).aspx) and [Web Application Projects versus Web Site Projects](http://msdn.microsoft.com/en-us/library/aa983476(v=vs.100).aspx) – RaphaelDDL May 14 '13 at 17:54
- Add a separate (empty) project (".buildstep"), to which you add your custom build step - you'll have to specify target folders to the main web project, but make use of the predefined environment variables (like $solutiondir, $platform, $mode etc).
- Add a dependency to this new project from the main web project (Project | Project Dependencies).
- Rebuild + verify build step has been carried out. You're done.
- ;o)

- 517
- 4
- 10
One of the major benefits of going the WAP (Web Application Projects) route rather than WSP (Website Projects) is that you get the ability to have Post Build events.
Therefore, it is not possible out of the box anyway. Here is the detail.

- 62,228
- 14
- 110
- 173
Maybe it is no relevant, but you can customize start options (make it run script/command) though it will be triggered only when you Launch project (Dubug -> Start).

- 93
- 1
- 3
One possible solution is creating an empty dummy C#/VB project without any files, and adding the necessary batch script as post build event there. Then, you can build that "project" right after you publish the web site - an extra mouse click but still better than running things manually. I went this route for our deployment packaging and it works great.

- 5,230
- 1
- 28
- 35
You can create publish profile for Web Site type applications. *.publishproj should be created. Then you can add there post and pre build commands as Targets.
<Target Name="BeforeBuildTarget" AfterTargets="BeforeBuild">
<Exec Command="cmd.exe"></Exec>
</Target>
<Target Name="AfterBuildTarget" AfterTargets="AfterBuild">
<Exec Command="cmd.exe"></Exec>
</Target>

- 8,309
- 2
- 38
- 46