title: Accessing TeamCity artifacts in Build Step
body: <p>I have been playing around with TeamCity to get a CI environment up and running.</p>
  
  <p>I started by following Troy Hunt's <a href="http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity.html" rel="nofollow">'You're deploying wrong'</a>, which was very useful, however I wanted to split the packaging and deployment into 2 seperate steps, for the following reasons:</p>
  
  <ol>
  <li>I wanted to pass some additional flags to msdeploy, which isnt possible (to m,y knowledge) by using the MSBuild Package and Deploy that Troy describes.</li>
  <li>I can easily disable the Second Build Step i.e. deployment, if I ever need to build the package but not deploy it.</li>
  <li>I wanted to use the -skip flag on msdeploy to prevent it from deleting certain folders, which again I couldn't find any method of doing without passing as an argument to the command line.</li>
  </ol>
  
  <p>So, in my first MSBuild step I just have the parameters:</p>
  
  <blockquote>
    <p>/P:Configuration=%env.Configuration%<br>
        /P:VisualStudioVersion=11.0<br>
        /P:IgnoreDeployManagedRuntimeVersion=True</p>
  </blockquote>
  
  <p>And then I have a second Build Step that uses a command line build runner to execute the following msdeploy command:</p>
  
  <pre><code>"C:\Program Files\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync       -source:package="C:\ProgramData\JetBrains\TeamCity\system\artifacts\MyProject\%system.teamcity.buildConfName%\%teamcity.build.id%\MyProject.Web.csproj.zip"   -dest:auto,ComputerName='https://devserver:8172/msdeploy.axd?site=MyWebsite',UserName='domain\username',Password='password',IncludeAcls='False',AuthType='Basic' -skip:objectName=dirPath,absolutePath=media$ -disableLink:AppPoolExtension -disableLink:ContentExtension   -disableLink:CertificateExtension -retryAttempts=2 -allowuntrusted
  </code></pre>
  
  <p>The problem with this is that apparently TeamCity doesnt publish the artifacts until all the build steps are complete, so therefore the Command Line process fails because the package zip file doesnt actually exist at that point.</p>
  
  <p>I have read something about <a href="http://confluence.jetbrains.com/display/TCD65/Build+Script+Interaction+with+TeamCity#BuildScriptInteractionwithTeamCity-PublishingArtifactswhiletheBuildisStillinProgress" rel="nofollow">publishing artifacts whilst the Build is still in progress</a> but that does seem like a bit of a hack.</p>
  
  <p>Any advice would be greatly appreciated.</p>