4

I'm trying to get my web application to deploy automatically at the end of an automated build and I'm obviously missing something.

My setup is:
VS2012 on a Win7 workstation
TFS2010 repository on serverA
TFS build agent on serverB
Test site in IIS7 on serverC.

I have created a quick test project using the default MVC4 template and created a Team Project to go with it using the MS VS Scrum 1.0 template.

I created a new publish profile for the web application using the publish web dialog and the .pubxml file is checked in with the project. The .pubxml file looks something like this:

<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <SiteUrlToLaunchAfterPublish>TestServer/DeployTest</SiteUrlToLaunchAfterPublish>
    <MSDeployServiceURL>http://TestServer</MSDeployServiceURL>
    <DeployIisAppPath>webapp-dev/DeployTest</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>RemoteAgent</MSDeployPublishMethod>
    <UserName>mydomain\myuser</UserName>
    <_SavePWD>True</_SavePWD>
    <PublishDatabaseSettings>
      <Objects xmlns="" />
    </PublishDatabaseSettings>
  </PropertyGroup>
</Project>

*some of the names have been changed to protect the innocent :)

Using this profile I can successfully publish the application from Visual Studio to the test web server without any issue. Following Scott Hanselman's blog post I successfully published from the command line on my workstation:

msbuild DeployTest.csproj /p:DeployOnBuild=true /p:PublishProfile=Test /p:AllowUntrustedCertificate=true /p:Password=notTheRealPassword

I then created a build in Team Explorer that would use my build server to compile and then run the unit tests. All good. The project builds, unit tests pass.

I then added the parameters from the command line to the MS Build Arguments in the Advanced section of the build definition:

/p:DeployOnBuild=true /p:PublishProfile=Test /p:AllowUntrustedCertificate=true /p:Password=notTheRealPassword

The build runs, the unit tests pass, nothing is published to the web server. :(

Can someone enlighten me as to what I have missed? Nothing I've read seems to indicate a step I have missed out but there's seemingly precious little documentation to explain how this is done.

Pankwood
  • 1,799
  • 5
  • 24
  • 43
Nick
  • 4,115
  • 10
  • 45
  • 57
  • The only difference, I believe, between those two deploy scenarios is the originator of the deployment. I would check your permissions. – Andrew Clear Oct 05 '12 at 14:56
  • The build service runs under a domain account which I have added to the Administrators group on the web server. It's the same account I used successfully in the command line test and the VS publish. – Nick Oct 05 '12 at 15:11

2 Answers2

1

It sounds like tfs might not support publish profiles.

You may need to pull out all the parameters from the profile and specify them manually.

Here's a similar question.

Team Build: Publish locally using MSDeploy

Community
  • 1
  • 1
Betty
  • 9,109
  • 2
  • 34
  • 48
0

I know this is an old question but today I ran into the same issue and I think I know the reason for the behavior you observed. Let me summarize the issue:

  1. You have create a web deploy publish profile.
  2. When you use the profile from command prompt with MSBuild command, the site is published successfully.
  3. But when you use this profile from the build definition (by specifying MS Build Arguments in the advanced section of the build definition) the site is not published.

I think the reason behind this is because you have VS 2012 on your workstation which supports publish using profile feature. Hence when you run the MS build from command prompt on your work-station the site is published. But the support for publish profile is not available on TFS 2010 hence with build server the site is not published.

I faced the same issue today and I did following to resolve the issue:

  1. On TFS machine, from the command prompt, I ran the MS Build command with publish profile. The command ran successfully but nothing got published (copied) on the site. This proves that TFS 2010 server does not support public profiles.
  2. I had VS 2010 deployed on the TFS machine. I installed web deploy 3.5 and Windows Azure SDK for Visual Studio 2010. This is the way to provide support for publish profile on VS 2010.
  3. Then I ran the MS Build command using published profile from command prompt and it published the site successfully.
  4. Then finally executed the build definition with MS Build parameters and the site got published successfully.

I know installing Visual studio on TFS machine not an ideal solution but at least it solved my problem. I am also not sure why installing VS 2010 with publish profile support resolved the issue. But it seems that, after the installation some of the missing components/dlls got deployed on the TFS machine which resolved the issue. Hope this resolves your deployment issue.

[UPDATE]: There could be another reason for the above behavior. Check the log messages of the build activity. If you find a warning similar to this: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets (484, 9): warning: The OutputPath property is not set for project ProjectName.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Release' Platform='Any CPU'

Then it may be related to build configuration. If you are using “Any CPU” as build configuration then change it to “AnyCPU” (remove space). Refer following link for the detailed explanation:

http://social.msdn.microsoft.com/Forums/vstudio/en-US/0bb277ec-a08c-4795-88f0-3207654e2560/the-outputpath-property-is-not-set-for-project-xxxxxbtproj-please-check-to-make-sure-that-you?forum=tfsbuild

Amey

Amey
  • 1,216
  • 18
  • 28