I\'m trying to get MSBuild 2010 to publish a web app to a specific location. I can get it to publish the deployment package to a particular path, but the deployment package
I think you're using the wrong property. Try the OutDir property instead.
<arg value="/property:OutDir=C:\dev\build\Output\Debug\" />
Personally, I call MsBuild.exe directly instead of using the msbuild tag:
<exec program="${MSBuildPath}">
<arg line='"${ProjectFile}"' />
<arg value="/target:_CopyWebApplication" />
<arg value="/property:OutDir=${LocalDeployPath}\" />
<arg value="/property:WebProjectOutputDir=${LocalDeployPath}" />
<arg value="/property:Configuration=${SolutionConfiguration}" />
<arg value="/verbosity:normal" />
<arg value="/nologo" />
</exec>
MSBuildPath - The path to MsBuild.exe (allows you to target any framework version you want)
ProjectFile - The relative path to your project file
LocalDeployPath - The local folder where everthing will be outputed. Your copy script will use also use this as the source directory.
SolutionConfiguration - Release, Debug
msbuild /t:Build;PipelinePreDeployCopyAllFilesToOneFolder /p:Configuration=Release;_PackageTempDir=C:\temp\somelocation;AutoParameterizationWebConfigConnectionStrings=false MyProject.csproj
Corresponding NAnt script:
<msbuild project="MyProject.csproj" target="PipelinePreDeployCopyAllFilesToOneFolder">
<property name="Configuration" value="Release" />
<property name="_PackageTempDir" value="C:\temp\somelocation" />
<property name="AutoParameterizationWebConfigConnectionStrings" value="false" />
</msbuild>
See also Team Build: Publish locally using MSDeploy
If you are using a VS2010 web application (as opposed to a web site project), consider setting up the Package/Publish Web settings in your project and building the 'Project' target in your nant script.
Lots of juicy msdeploy goodness and background here: http://www.hanselman.com/blog/WebDeploymentMadeAwesomeIfYoureUsingXCopyYoureDoingItWrong.aspx
In my nant scripts, I run the following msbuild commands:
<if test="${property::exists('basename')}">
<exec program="${msbuild.location}" workingdir="${project::get-base-directory()}">
<arg value="/p:Configuration=${configuration}" />
<arg value="/logger:ThoughtWorks.CruiseControl.MsBuild.XmlLogger,${msbuild.logger.dll}" if="${nunit.formatter.type == 'Xml'}"/>
<arg value="/noconsolelogger" if="${nunit.formatter.type == 'Xml'}"/>
<arg value="${basename}.sln"/>
</exec>
</if>
...
<if test="${property::exists('basename')}">
<exec program="${msbuild.location}" workingdir="${project::get-base-directory()}\${basename}">
<arg value="/p:Configuration=${configuration}" />
<arg value="/t:Package" />
<arg value="/logger:ThoughtWorks.CruiseControl.MsBuild.XmlLogger,${msbuild.logger.dll}" if="${nunit.formatter.type == 'Xml'}"/>
<arg value="/noconsolelogger" if="${nunit.formatter.type == 'Xml'}"/>
<arg value="${basename}.csproj"/>
</exec>
</if>
My basename nant variable gives the name of both the VS solution file (.sln) and the project file (.csproj) for the web application. I happen to prefer the zip-file deployment as shown in my project settings:
There is one additional quirk. If you install MSDeploy version 2.0 on the target machine, the .deploy.cmd file must be edited to change the MSDeploy version number as follows:
Change
for /F "usebackq tokens=2*" %%i in (`reg query "HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\1" /v InstallPath`) do (
To
for /F "usebackq tokens=2*" %%i in (`reg query "HKLM\SOFTWARE\Microsoft\IIS Extensions\MSDeploy\2" /v InstallPath`) do (