1

We're using MSDeploy with a Web Deployment Project to deploy our web site project using TFS Builds (TFS 2010 and VS 2010).

TFS Build sends the built files to a sub-folder of the specified drop folder, so if I specify the drop folder as:

\\machineName\Builds

The build project is dropped into:

\\machineName\Builds\1. Test\20120226.38\Deploy

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.

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:

<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Test|AnyCPU' ">
    <DeploySource Include="DirPath">
        <Path>C:\Builds\1. Test\20120226.39\_PublishedWebsites\Deploy</Path>
        <ComputerName>machineName</ComputerName>
        <UserName>$(UserName)</UserName>
        <Password>$(Password)</Password>
    </DeploySource>
</ItemGroup>

To account for a changing build number and date, I've added a $(BuildNumber) variable via the DefaultTemplate.xaml file. So, here's the subtly changed example:

<ItemGroup Condition=" '$(Configuration)|$(Platform)' == 'Test|AnyCPU' ">
    <DeploySource Include="DirPath">
        <Path>C:\Builds\1. Test\$(BuildNumber)\_PublishedWebsites\Deploy</Path>
        <ComputerName>machineName</ComputerName>
        <UserName>$(UserName)</UserName>
        <Password>$(Password)</Password>
    </DeploySource>
</ItemGroup>

And they're passed into this MSDeploy call:

<MSDeploy  Condition=" '$(Configuration)|$(Platform)' == 'Test|AnyCPU' "
    Whatif="$(WhatIf)"
    Verb="sync"
    Source="@(DeploySource)"
    Destination="@(DeployDest0)"
    ExePath="$(MSDeployPath)"
/>

Here's my problem:

With example 1 above, everything's fine, and the build site deploys to the correct location.

With example 2 above, I get the following error:

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'.

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.

Note: This is a web site project, not a web application project. Time constraints and black-box vendor dependencies won't allow a conversion.

Community
  • 1
  • 1
ThisGuyKnowsCode
  • 530
  • 4
  • 18
  • Question: In your working example where you've hard-coded the build number, is that a pre-existing build where the folder existed prior to your invocation of the command? If so, then I'd guess that the problem is likely the order of operations, meaning the folder you've indicated with $(BuildNumber) doesn't exist when the path is evaluated and MSDeploy is ran, but instead is created later in the build process. – Nick Nieslanik Feb 28 '12 at 04:23
  • I've tried this with both pre-existing paths, and with the new path the build will be creating. Unfortunately, same results in both cases. – ThisGuyKnowsCode Feb 28 '12 at 15:45
  • Have you tried using $(OutDir) as my answer suggests? – Nick Nieslanik Feb 28 '12 at 15:47

1 Answers1

3

If in your working example where you've hard-coded the build number the build output folder existed prior to your invocation of the command then I'd guess that the problem is likely the order of operations, meaning the folder you've indicated with $(BuildNumber) doesn't exist when the path is evaluated and MSDeploy is ran, but instead is created later in the build process.
In fact, I'd bet you need to use another TFS variable to indicate the build location like

 $(OutDir)\_PublishedWebsites\Deploy
Nick Nieslanik
  • 4,388
  • 23
  • 21
  • I feel silly, I just realized OutDir will allow me to deploy from the build server instead of from the drop location. I can't deploy from the drop location unless I have the XAML file do it (I think). If I get the path right, it should work. I may just need to mess with the paths before I mark this as the answer. Thanks Nick! – ThisGuyKnowsCode Feb 28 '12 at 21:51
  • well frankly I'm surprised that $(OutDir) didn't work since I believe it's not the same thing as the final drop copy location. TFS2010 uses workflow to perform the pre & post build tasks so the copy to the drop share happens in a CodeActivity after MSBuild is finished. Another option might be to use $(BinariesRoot) (check out this MSDN article on TFS build properties http://msdn.microsoft.com/en-us/library/aa337598.aspx ) – Nick Nieslanik Feb 28 '12 at 21:58
  • Thanks again Nick, I've ironed out all the kinks. – ThisGuyKnowsCode Feb 28 '12 at 22:52
  • Just saw you last reply "well frankly I'm surprised...", I just want to clarify $(OutDir) ended up working great for me after all. – ThisGuyKnowsCode Feb 28 '12 at 22:53
  • awesome. apparently we posted at the exact same time :) – Nick Nieslanik Feb 28 '12 at 23:04