Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I got it mostly working without a custom msbuild script. Here are the relevant TeamCity build configuration settings:</p> <pre> Artifact paths: %system.teamcity.build.workingDir%\MyProject\obj\Debug\Package\PackageTmp Type of runner: MSBuild (Runner for MSBuild files) Build file path: MyProject\MyProject.csproj Working directory: same as checkout directory MSBuild version: Microsoft .NET Framework 4.0 MSBuild ToolsVersion: 4.0 Run platform: x86 Targets: Package Command line parameters to MSBuild.exe: /p:Configuration=Debug </pre> <p>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.</p> <p><strong>Update</strong></p> <p>Here is an msbuild script that will compile, package (with web.config transformation), and copy the output to my staging server</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8" ?&gt; &lt;Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"&gt; &lt;PropertyGroup&gt; &lt;Configuration Condition=" '$(Configuration)' == '' "&gt;Release&lt;/Configuration&gt; &lt;SolutionName&gt;MySolution&lt;/SolutionName&gt; &lt;SolutionFile&gt;$(SolutionName).sln&lt;/SolutionFile&gt; &lt;ProjectName&gt;MyProject&lt;/ProjectName&gt; &lt;ProjectFile&gt;$(ProjectName)\$(ProjectName).csproj&lt;/ProjectFile&gt; &lt;/PropertyGroup&gt; &lt;Target Name="Build" DependsOnTargets="BuildPackage;CopyOutput" /&gt; &lt;Target Name="BuildPackage"&gt; &lt;MSBuild Projects="$(SolutionFile)" ContinueOnError="false" Targets="Rebuild" Properties="Configuration=$(Configuration)" /&gt; &lt;MSBuild Projects="$(ProjectFile)" ContinueOnError="false" Targets="Package" Properties="Configuration=$(Configuration)" /&gt; &lt;/Target&gt; &lt;Target Name="CopyOutput"&gt; &lt;ItemGroup&gt; &lt;PackagedFiles Include="$(ProjectName)\obj\$(Configuration)\Package\PackageTmp\**\*.*"/&gt; &lt;/ItemGroup&gt; &lt;Copy SourceFiles="@(PackagedFiles)" DestinationFiles="@(PackagedFiles-&gt;'\\build02\wwwroot\$(ProjectName)\$(Configuration)\%(RecursiveDir)%(Filename)%(Extension)')"/&gt; &lt;/Target&gt; &lt;/Project&gt; </code></pre> <p>You can also remove the SolutionName and ProjectName properties from the PropertyGroup tag and pass them to msbuild.</p> <pre><code>msbuild build.xml /p:Configuration=Deploy;SolutionName=MySolution;ProjectName=MyProject </code></pre> <p><strong>Update 2</strong></p> <p>Since this question still gets a good deal of traffic, I thought it was worth updating my answer with my current script that uses <a href="http://www.iis.net/download/WebDeploy" rel="noreferrer">Web Deploy</a> (also known as MSDeploy).</p> <pre><code>&lt;Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build" ToolsVersion="4.0"&gt; &lt;PropertyGroup&gt; &lt;Configuration Condition=" '$(Configuration)' == '' "&gt;Release&lt;/Configuration&gt; &lt;ProjectFile Condition=" '$(ProjectFile)' == '' "&gt;$(ProjectName)\$(ProjectName).csproj&lt;/ProjectFile&gt; &lt;DeployServiceUrl Condition=" '$(DeployServiceUrl)' == '' "&gt;http://staging-server/MSDeployAgentService&lt;/DeployServiceUrl&gt; &lt;/PropertyGroup&gt; &lt;Target Name="VerifyProperties"&gt; &lt;!-- Verify that we have values for all required properties --&gt; &lt;Error Condition=" '$(ProjectName)' == '' " Text="ProjectName is required." /&gt; &lt;/Target&gt; &lt;Target Name="Build" DependsOnTargets="VerifyProperties"&gt; &lt;!-- Deploy using windows authentication --&gt; &lt;MSBuild Projects="$(ProjectFile)" Properties="Configuration=$(Configuration); MvcBuildViews=False; DeployOnBuild=true; DeployTarget=MSDeployPublish; CreatePackageOnPublish=True; AllowUntrustedCertificate=True; MSDeployPublishMethod=RemoteAgent; MsDeployServiceUrl=$(DeployServiceUrl); SkipExtraFilesOnServer=True; UserName=; Password=;" ContinueOnError="false" /&gt; &lt;/Target&gt; &lt;/Project&gt; </code></pre> <p>In TeamCity, I have parameters named <code>env.Configuration</code>, <code>env.ProjectName</code> and <code>env.DeployServiceUrl</code>. 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).</p> <p>You can also run it from the command line:</p> <pre><code>msbuild build.xml /p:Configuration=Staging;ProjectName=MyProject;DeployServiceUrl=http://staging-server/MSDeployAgentService </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload