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