AndersDaniel
AndersDaniel

Reputation: 1162

Customize properties for MSDeploy via Nant or VS2010

I have a web application that I want to deploy using MSDeploy. I have a Nant script that runs MSBuild and has the property DeployOnBuild set to true. It creates a deployment package that I use on a server.

What I want to do is to avoid that MSDeploy deletes the content of the destination folder before it deploys the new files. I can do it manually by adding -enableRule:DoNotDeleteRule to my command line, but I would like MSDeploy to do it manually. I really need some help with that.

I'm using Visual Studio 2010 and if there was a way to make this setting from there it would be optimal. If it's possible to do it from Nant that also great.

Summary: The deployment package created with MSBuild via Nant should have the flag -enableRule:DoNotDeleteRule by default.

Upvotes: 0

Views: 597

Answers (2)

AndersDaniel
AndersDaniel

Reputation: 1162

We ended up using the Nant command for creating a bat file, and then we added the -enableRule to the command in that file:

<echo file="..\..\Packages\${stage}\${project::get-name()}.${stage}.Run.TestDeploy.bat">
        %CD%\${project::get-name()}.${stage}.deploy.cmd /T -enableRule:DoNotDeleteRule
        PAUSE
    </echo>

    <echo file="..\..\Packages\${stage}\${project::get-name()}.${stage}.Run.REALDEPLOY.bat">
        %CD%\${project::get-name()}.${stage}.deploy.cmd /Y -enableRule:DoNotDeleteRule
        PAUSE
    </echo>

The /T and /Y flags are used in MSDeploy to know whether you are testing the script (/T) or if you're running it for real (/Y).

This is a workaround, but we're satisfied with it.

Upvotes: 1

Brian Kretzler
Brian Kretzler

Reputation: 9938

Set the property $(SkipExtraFilesOnServer) to the value "true", either in a project or shared import file,

<PropertyGroup>
   <SkipExtraFilesOnServer>true</SkipExtraFilesOnServer>
</PropertyGroup>

or on your command line from Nant,

/p:SkipExtraFilesOnServer=true

See the file Microsoft.Web.Publishing.targets (search for "MSDeploy") for more options.

Upvotes: 3

Related Questions