views:

498

answers:

2

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 then adds its own path that changes.

For example: if I tell it to publish to C:\dev\build\Output\Debug then the actual web files end up at C:\dev\build\Output\Debug\Archive\Content\C_C\code\app\Source\ControllersViews\obj\Debug\Package\PackageTmp And the C_C part of the path changes (not sure how it chooses this part of the path).

This means I can't just script a copy from the publish location.

I'm using this nant/msbuild command at the moment:

  <target name="compile" description="Compiles">
<msbuild project="${name}.sln">

  <property name="Platform" value="Any CPU"/>
  <property name="Configuration" value="Debug"/>
  <property name="DeployOnBuild" value="true"/>
  <property name="DeployTarget" value="Package"/>
  <property name="PackageLocation" value="C:\dev\build\Output\Debug\"/>
  <property name="AutoParameterizationWebConfigConnectionStrings" value="false"/>
  <property name="PackageAsSingleFile" value="false"/>

</msbuild>

Any ideas on how to get it to send the web files directly to a specific location?

A: 

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

Babak Naffas
+3  A: 
msbuild /t:Build;PipelinePreDeployCopyAllFilesToOneFolder /p:Configuration=Release;_PackageTempDir=C:\temp\somelocation MyProject.csproj

See Simulating "Publish to folder" Functionality in Visual Studio 2010

Pavel Chuchuva