Paul Michaels
Paul Michaels

Reputation: 16695

Deploying a WCF Web Service inside a TFS Build

I have a number of WCF web services that I am trying to deploy to a directory structure on a TFS Build. The project structure looks something like this:

Services Directory (svc.sln)
- Project1 (project1.csproj)
- Project2 (project2.csproj)
- Project3 (project3.csproj)
- ServicesProject
  - Project1
    - Project1.svc
  - Project2
    - Project2.svc
  - Project3
    - Project3.svc
  - bin
    - Project1.dll
    - Project2.dll
    - Project3.dll

So, In order to deploy this, on my desktop, I simply load ServicesProject.csproj, publish, select a publish profile and it will happily publish to a single directory (ready to be copied across to IIS).

I then tried to add this to a TFS build, using the arguments:

/p:DeployOnBuild=true /p:PublishProfile=MyPublishProfile

I got an error, saying that:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\WebApplications\Microsoft.WebApplication.targets (182): Could not copy the file "bin\Project1.dll" because it was not found.

I had a look in the agent build directory and, sure enough, there was only one dll in there (ServicesProject.dll). I then changed the build to build svc.sln, but I still get the same error. I checked the build order for the sln file, and it does have ServicesProject last, however, the log file indicates that it gets built second.

I've provided so much detail, in case the answer to this lies in the approach I'm taking, rather than the specifics of what I'm actually doing.

My question is: am I doing this correctly and, if so, why is the sln file being build in the wrong order. Is there an easier way to achieve this?

Upvotes: 0

Views: 1410

Answers (1)

I would suggest that any deployment from TF Build is the wrong way to achieve this. You should instead look to output the website, which is automatic, and deploy it using Release Management.

http://nakedalm.com/create-release-management-pipeline-professional-developers/

RM is built into TFS, all though you need to install it separately, and lets you create a deployment using PowerShell. It's very easy to do deployment and configuration of your website, and in the post you can see switching variables is also trivial.

Much easyer than trying to shoehorn deployment into a build tool.

Upvotes: 1

Related Questions