How you automatically package (MSDeploy) a web application project as part of the project. Creating a Visual Studio IDE?

I have a web application project in Visual Studio 2010 that is configured with MS Deploy settings. I can right-click the project in Solution Explorer and run the "Build Deployment Package", which tells MSDeploy to create a zip file for deployment. It depends on the build purpose for the project. Everything that works.

The problem is that I cannot figure out how to get the MSDeploy packaging functionality to run as part of the Build object in Visual Studio. In other words, when I right-click a project in Solution Explorer and click "Old", I would like it to run the "build deployment package" as well.

“Why not just click Build Deployment Package, then ask? Because I really want the build goal of my web application to be dependent on another project in my solution, which is a WIX installer. In other words, a WIX project has one dependency which is my web application project. When I create a WIX project, VS automatically creates a web application project but does not create a deployment package. The WIX installer uses the deployment package as part of the installation process. In this workflow, either The WIX installer will not be created because it will not be able to find the files created by MSDeploy (bad), or it will find the outdated MSDeploy package and use it without complaint (very bad). It sounds superfluous to use both MSDeploy and Microsoft Installer, but I take the lines from here . I like the idea of ​​having an MSI that can be linked to other MSIs or included in a GPO application.

If I just try to manually add the “Package” as a post-build event to the web application project by pasting it into the csproj source XML file:

<Target Name="AfterBuild"> <CallTarget Targets="Package" /> </Target> 

then a simple old assembly will fail because it will depend on the package, and apparently the purpose of the package depends on the assembly. Which is circular.

Maybe I really want the WIX installer project to depend on the output of the goal “Build deployment package” or “Use deployment build package” instead of “Build” in my Project Dependency Graph. Any ideas on this?

I do not think that I need an MSBuild script that should be executed from the command line, as when executing the planned TFS TeamBuild. I would like to save this as a VisualStudio task, performed by the developer (me) using a monitor, keyboard and mouse randomly and many times a day. In fact, I want to say that I do not have access to TFS at all.

+4
source share
3 answers

Well, therefore, to answer my own question ...

Just add “; Package” to the list of default build goals at the very top of the project file in question, for example:

 <Project ToolsVersion="4.0" DefaultTargets="Build;Package" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> 

This is line 2 of my csproj file. Now, when you click Build, the project also performs the MSDeploy Packaging task. And, when another project depends on this web application project and another project is usually created through VS, the goal of MSDeploy packaging is fulfilled over time.

And everything is right with the world. Why is it so difficult to research, and why do I need to manually edit the project file to complete this? Do not respond to this.

+3
source

Add the following property to the MSBuild arguments:

 /property:DeployOnBuild=true 
+1
source

Adding a Package target works fine until you want to use different publishing profiles. I found that you can add a publication profile as an element of a property group to your .csproj file, as shown below:

 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU'"> <PlatformTarget>$(Platform)</PlatformTarget> <PublishProfile>ServerDebug</PublishProfile> ... </PropertyGroup> 

Follow the steps above for each Configuration / Platform combination and set the desired profile.

+1
source

All Articles