Visual Studio 2010 has a Publish command that allows you to publish your Web Application Project to a file system location. I'd like to do this on my TeamCity build server, so I need to do it with the solution runner or msbuild. I tried using the Publish target, but I think that might be for ClickOnce:
msbuild Project.csproj /t:Publish /p:Configuration=Deploy
I basically want to do exactly what a web deployment project does, but without the add-in. I need it to compile the WAP, remove any files unnecessary for execution, perform any web.config transformations, and copy the output to a specified location.
My Solution, based on Jeff Siver's answer
<Target Name="Deploy">
<MSBuild Projects="$(SolutionFile)"
Properties="Configuration=$(Configuration);DeployOnBuild=true;DeployTarget=Package"
ContinueOnError="false" />
<Exec Command=""$(ProjectPath)\obj\$(Configuration)\Package\$(ProjectName).deploy.cmd" /y /m:$(DeployServer) -enableRule:DoNotDeleteRule"
ContinueOnError="false" />
</Target>
Best Answer
I got it mostly working without a custom msbuild script. Here are the relevant TeamCity build configuration settings:
This will compile, package (with web.config transformation), and save the output as artifacts. The only thing missing is copying the output to a specified location, but that could be done either in another TeamCity build configuration with an artifact dependency or with an msbuild script.
Update
Here is an msbuild script that will compile, package (with web.config transformation), and copy the output to my staging server
You can also remove the SolutionName and ProjectName properties from the PropertyGroup tag and pass them to msbuild.
Update 2
Since this question still gets a good deal of traffic, I thought it was worth updating my answer with my current script that uses Web Deploy (also known as MSDeploy).
In TeamCity, I have parameters named
env.Configuration
,env.ProjectName
andenv.DeployServiceUrl
. The MSBuild runner has the build file path and the parameters are passed automagically (you don't have to specify them in Command line parameters).You can also run it from the command line: