I want add a command line in the pre-build event, but there is no build event for web site. After search internet, it seems web site not support build event. So I want to know the reason why it not support? And if I real want to execute my pre-build event, any idea? Thanks in advance.
1 Answers
So I want to know the reason why it not support? And if I real want to execute my pre-build event, any idea?
Just as you know build event isn't supported for web sites, you'll need to use a web application project. So you could convert web site project to Web application. See the question and its answers for more information: ASP.NET Web Site or ASP.NET Web Application?.
As far as I know, the reason why website not support build event is that Visual Studio doesn't really ever build Web Sites itself. You can run Build command that from VS, but all it does is basically check that your site can build without error. The key point is that when you build a Web Site from VS, it does not produce any build artifacts at all. Instead, everything that needs to be built happens at run-time when you send http requests to the site.
If you real want to add a build event to website, you can add a blank project(e.g. a library) reference your website, then add the build event on the reference project. With the project dependency, you'll be guaranteed that the build event is always built before the Web Site.

- 71,098
- 10
- 114
- 135