We have some custom MS Build scripts that generates code and configuration files for web application projects when they build. Currently we call these build scripts by overriding the “BeforeBuild” and “AfterBuild” targets in the .csproj file of the web project. However, in another solution I have a web site project which is opened directly from the local IIS and has no .csproj file. How can I customize the build of this type of project?
If it is not possible to customize the MS Build process of the web site, it would be good enough to invoke something like a .bat file which that would run my custom MS Build script. We are currently using a .bat file but the developers have to manually run it but they sometimes forget this. I can’t see a simple way to kick it off automatically when clicking build.
I would like something that runs as part of the solution build, both in Visual Studio and Team Build.
I have now achieved what I need by adding a separate MS Build file in my solution and ensuring it builds before the web site by using the project dependencies in Visual Studio.
The actual build file is quite minimal and is called “Configure.csproj” and sits in the root of the web site:
Right-click the solution and choose “Add existing project” and select this file.
It seems odd to have this named *.csproj when there is no C# to build, but this file extension is one recognised by Visual Studio when clicking “Add existing project”.
Then to make sure this is built before the web site, right-click the solution and choose “Project dependencies”. Select the web site project from the “Projects” drop-down list and then check the box next to “Configure”.
It is of course possible to run a custom build after the web site by adding another project and adding a dependency on the web site.