Search code examples
visual-studio-2010msbuildmsdeploy

Build website deployment package as a postbuild event


I am using visual studio 2010. I have a website project that I would like to build a website deployment package every time I build a the project. Basically I am looking for some example of a post build MSBuild command that will basically do the same thing as the "Build Deployment Package" option from the right click menu of the website.


Solution

  • I assume you are using Web Application Projects, because Web Site projects do not have the "Build Deployment Package".

    I would recommend not performing a package on every build, because it will slow down your development drastically. With that being said, you can do it here is how.

    If you really wanted to do this your best bet is not to use post-build event, but to edit the project file and extend the build process. To do this open the .csproj file for your web and then towards the bottom (after the Import elements) place the following

    <PropertyGroup>
      <BuildDependsOn>
        $(BuildDependsOn);
        Package
      </BuildDependsOn>
    </PropertyGroup>
    

    What this does is extend the build process to call the Package target. This is the same target that is called when you invoke the "Build Deployment Package" target in Visual Studio.