title: MSDeploy won't accept dynamic path for deploy destination
body: <p>We're using MSDeploy with a Web Deployment Project to deploy our web site project using TFS Builds (TFS 2010 and VS 2010).</p>
  
  <p>TFS Build sends the built files to a sub-folder of the specified drop folder, so if I specify the drop folder as:</p>
  
  <blockquote>
    <p>\\machineName\Builds</p>
  </blockquote>
  
  <p>The build project is dropped into:</p>
  
  <blockquote>
    <p>\\machineName\Builds\1. Test\20120226.38\Deploy</p>
  </blockquote>
  
  <p>In that example, "1. Test" is the name of the TFS Build definition, "20120226.38" is a date-stamp and build number, and "Deploy" is the name of the Web Deployment Project.</p>
  
  <p>When I create my DeploySource itemgroup in the Deploy.wdproj file, and specify the exact path for the MSDeploy source (see directly below) everything's fine. Example:</p>
  
  <pre>
  &lt;ItemGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'Test|AnyCPU' &quot;&gt;
      &lt;DeploySource Include=&quot;DirPath&quot;&gt;
          &lt;Path&gt;C:\Builds\1. Test\20120226.39\_PublishedWebsites\Deploy&lt;/Path&gt;
          &lt;ComputerName&gt;machineName&lt;/ComputerName&gt;
          &lt;UserName&gt;$(UserName)&lt;/UserName&gt;
          &lt;Password&gt;$(Password)&lt;/Password&gt;
      &lt;/DeploySource&gt;
  &lt;/ItemGroup&gt;
  </pre>
  
  <p>To account for a changing build number and date, I've <a href="https://stackoverflow.com/questions/7330353/how-to-get-buildnumber-in-proj-msbuild-using-tfs-server">added a $(BuildNumber) variable via the DefaultTemplate.xaml file</a>. So, here's the subtly changed example:</p>
  
  <pre>
  &lt;ItemGroup Condition=&quot; '$(Configuration)|$(Platform)' == 'Test|AnyCPU' &quot;&gt;
      &lt;DeploySource Include=&quot;DirPath&quot;&gt;
          &lt;Path&gt;C:\Builds\1. Test\<b>$(BuildNumber)</b>\_PublishedWebsites\Deploy&lt;/Path&gt;
          &lt;ComputerName&gt;machineName&lt;/ComputerName&gt;
          &lt;UserName&gt;$(UserName)&lt;/UserName&gt;
          &lt;Password&gt;$(Password)&lt;/Password&gt;
      &lt;/DeploySource&gt;
  &lt;/ItemGroup&gt;
  </pre>
  
  <p>And they're passed into this MSDeploy call:</p>
  
  <pre>
  &lt;MSDeploy  Condition=&quot; '$(Configuration)|$(Platform)' == 'Test|AnyCPU' &quot;
      Whatif=&quot;$(WhatIf)&quot;
      Verb=&quot;sync&quot;
      Source=&quot;@(DeploySource)&quot;
      Destination=&quot;@(DeployDest0)&quot;
      ExePath=&quot;$(MSDeployPath)&quot;
  /&gt;
  </pre>
  
  <p>Here's my problem:</p>
  
  <p>With example 1 above, everything's fine, and the build site deploys to the correct location.</p>
  
  <p>With example 2 above, I get the following error:</p>
  
  <pre>
  MSDEPLOY: Object of type 'dirPath' and path '\\machineName\Builds\1. Test\20120227.2\_PublishedWebsites\Deploy' cannot be created.
  MSDEPLOY: (2/27/2012 6:54:14 PM) An error occurred when the request was processed on the remote computer.
  MSDEPLOY: Object of type 'dirPath' and path '\\machineName\Builds\1. Test\20120227.2\_PublishedWebsites\Deploy' cannot be created.
  MSDEPLOY: Could not find directory '\\machineName\Builds\1. Test\20120227.2\_PublishedWebsites\Deploy'.
  MSDEPLOY: Could not find a part of the path '\\?\UNC\machineName\Builds\1. Test\20120227.2\_PublishedWebsites\Deploy'.
  </pre>
  
  <p>Checking out and manually changing the build number isn't a realistic option. I feel like there's something simple I'm missing here, but I can't put my finger on it.</p>
  
  <p>Note: This is a web site project, not a web application project. Time constraints and black-box vendor dependencies won't allow a conversion.</p>