Category Archives: 9767

Building Azure Cloud Applications on TFS

If you are doing any work with Azure Cloud Applications there is a very good chance you will want your automated build process to produce the .CSPKG deployment file, you might even want it to do the deployment too.

On our TFS build system, it turns out this is not a straight forward as you might hope. The problem is that the MSbuild publish target that creates the files creates them in the $(build agent working folder)\source\myproject\bin\debug folder. Unlike the output of the build target which puts them in the $(build agent working folder)\binaries\ folder which gets copied to the build drops location. Hence though the files are created they are not accessible with the rest of the built items to the team.

I have battled to sort this for a while, trying to avoid the need to edit our customised TFS build process template. This is something we try to avoid where possible, favouring environment variables and MSbuild arguments where we can get away with it. There is no point denying that editing build process templates is a pain point on TFS.

The solution – editing the process template

Turns out a colleague had fixed the same problem a few projects ago and the functionality was already hidden in our standard TFS build process template. The problem was it was not documented; a lesson for all of us, that it is a very good idea to put customisation information in a searchable location so others find customisations that are not immediate obvious. Frankly this is one of the main purposes of this blog, somewhere I can find what I did that years, as I won’t remember the details.

Anyway the key is to make sure the publish target for the MSBbuild uses the correct location to create the files. This is done using a pair of MSBuild arguments in the advanced section of the build configuration

  • /t:MyCloudApp:Publish –  this tells MSbuild to perform the publish action for just the project MyCloudApp. You might be able to just go /t:Publish if only one project in your solution has a Publish target
  • /p:PublishDir=$(OutDir) – this is the magic. We pass in the temporary variable $(OutDir). At this point we don’t know the target binary location as it is build agent/instance specific, customisation in the TFS build process template converts this temporary value to the correct path.

In the build process template in the Initialize Variable sequence within Run on Agent add a If Activity.


  • Set the condition to MSBuildArguments.Contains(“$(OutDir)”)
  • Within the true branch add an Assignment activity for the MSBuildArguments variable to MSBuildArguments.Replace(“$(OutDir)”, String.Format(“{0}\{1}\\”, BinariesDirectory, “Packages”))

This will swap the $(OutDir) for the correct TFS binaries location within that build.

After that it all just works as expected. The CSPKG file etc. ends up in the drops location.

Other things that did not work (prior to TFS 2013)

I had also looked a running a PowerShell script at the end of the build process or adding an AfterPublish target within the MSBuild process (by added it to the project file manually) that did a file copy. Both these methods suffered the problem that when the MSBuild command ran it did not know the location to drop the files into. Hence the need for the customisation above.

Now I should point out that though we are running TFS 2013 this project was targeting the TFS 2012 build tools, so I had to use the solution outlined above, a process template edit. However, if we had been using the TFS 2013 process template as our base for customisation then we would have had another way to get around the problem.

TFS 2013 exposes the current build settings as environment variables. This would allow us to use a AfterPublish MSBuild Target something like

<Target Name="CustomPostPublishActions" AfterTargets="AfterPublish" Condition="'$(TF_BUILD_DROPLOCATION)' != ''">
  <Exec Command="echo Post-PUBLISH event: Copying published files to: $(TF_BUILD_DROPLOCATION)" />
  <Exec Command="xcopy &quot;$(ProjectDir)bin\$(ConfigurationName)\app.publish&quot; &quot;$(TF_BUILD_DROPLOCATION)\app.publish&quot; /y " />

So maybe a simpler option for the future?

The moral of the story document your customisations and let your whole team know they exist

Black Marble is hosting the Yorkshire Chapter of the Global Windows Azure Bootcamp on the 27th of April

Black Marble is hosting the Yorkshire Chapter of the Global Windows Azure Bootcamp taking place in several locations globally on the April 27th, 2013. This free community organised event is one day deep dive class where you will get you up to speed on developing for Windows Azure. The class includes a trainer with deep real world experience with Windows Azure, as well as a series of labs so you can practice what you just learned.

Black Marble’s event will be run by Robert Hogg (Microsoft Integration MVP) and Steve Spencer (Windows Azure MVP). Come along and join the global Azure event of the year!

Check out the prerequisites you need to install on your PC and here to sign up

Global Azure Bootcamp Logo

A fix for my failure to login to problems

I use a number of site collections on the Azure hosted Team Foundations Service (; I have just solved a problem that I could not login to one of them via Visual Studio (2010, Dev11 or also TEE 11, I tried then all), but I could login to my other collections. Also I could access the collection if I logged in via a browser, just not with VS; all very good for work item management, but not much help for source code check-ins.

The Problem

The problem was that when I loaded Visual Studio and tried to select the collection in Team Explorer the ‘Sign into Team Foundation Server’ form loaded and uploaded a few times whilst trying to redirect to an authentication provider. I then ended up with a TF31003 error. A retry or use of different credentials did not help


If a deleted the server from the list and tried to re-add it I got similar results, but ended up at the LiveID sign in screen, but just an error message and no means to enter details.


The Solution

The problem was due to cached LiveID credentials. It was suggested I clear IE9 cookies but this did not help. In the end I found the solution in the Credential Manager (Control Panel > User Accounts > Manage Users > Advanced > Manage Passwords).

I had recently installed Skydrive on my PC. This had stored a cached LiveID, the issue was it seems this cached Skydrive LiveID was being used to access TFSpreview. Unfortunately this was my personal LiveID not my work one. This personal LiveID had no rights to access the problem site collection, but I could get into the other collections because both my personal and work LiveID both had access.

So I deleted the offending cached LiveID and tried Team Explorer again and this time I was prompted for a LiveID (though the user name field did contain the wrong LiveID, I could correct it) and I could login.


I then loaded SkyDrive (which I had exited) it prompted me to re-enter my credential. It recreated it cached credentials and seemed happy.

Interestingly they did not seem to cause a problem this time, maybe it is an entry order issue?

I need to keep an eye on it.

PDC 2010 thoughts – the next morning

I sat in the office yesterday with a beer in my hand watching the PDC2010 keynote. I have to say I preferred this to the option of a flight, jet lag and a less than comfortable seat in a usually overly cooled conference hall. With the Silverlight streaming the experience was excellent, especially as we connected an Acer 1420P to our projector/audio via a single HDMI cable and it just worked.

So what do you lose by not flying out? Well the obvious is the ‘free’ Windows Phone 7 the attendees got; too many people IMHO get hooked up on the swag at conferences, you go for knowledge not toys. They also forget they (or their company) paid for item anyway in their conference fee. More seriously you miss out on the chats between the sessions, and as the conference is on campus the easier access to the Microsoft staff. Also the act of travelling to a conference isolates you from the day to day interruptions of the office, the online experience does not and you will have to stay up late to view sessions live due to timezones. The whole travelling experience still cannot be replaced by the online experience, not matter how good the streaming.

However, even though I don’t get the ‘conference corridor experience’ it does not mean I cannot check out sessions, it is great to see they are all available free and live, or immediately available recordings if I don’t want to stay up.

The keynote was pretty much as I had expected. There were new announcements but nothing that was ground breaking, but good vNext steps. I thought the best place to start for me was the session “Lessons learned from moving team foundation server to the cloud”, this was on TFS, and obvious area of interest for me, but more importantly no real world experience to move a complex application to Azure. This is something that is going to effect all of us if Microsoft’s bet on the cloud is correct. Seems, though there are many gottas, the process was not as bad as you would expect. For me the most interesting point was the port to Azure caused changes to the codebase that actually improved the original implementation either in manageability or performance. Also that many of the major stumbling blocks were business/charging models not technology. This is going to effect us all as we move to service platforms like Azure or even internally host equivalents like AppFabic

So one session watched, what to watch next?

Post PDC Thoughts

I realised I never did another post after my first at the PDC, now what does that tell you?

One thing it tells me is that blogs are not they primary news form for events now, it has moved onto . Though as yet I am still lagging behind on this one, I have an account but no tweets as yet. I find there is too much noise most of the on Twitter, it is useful when at an event like PDC to get the buzz, but for me not day to day (though I know I am missing stuff because of this view)

For me the key story a the PDC as a whole was that the Azure fabric can extend into your IT systems using AppFabric. This means I can easily see a day where you write an application for an internal IT system that can dynamically grow to an Azure data centre when needed for load or disaster recover, all without any special coding model because the Azure/AppFabic is ubiquitous.

So a light PDC from the blogging front, but one for of future architectural promise

Oh one last thought, on past trips to the USA I have been to the Baseball, which I like, not that dissimilar a night out to one at the Twenty20 cricket. This time we tried Basketball, less to my taste. When watched live it seem the game play just gets in the way of the adverts and the other various audience participation entertainment. I have never seen a sport with so many ways to stop and clock (and for so long!). Looks like I need to stay with bat and ball games.

PDC Keynote Day 1 thoughts

So the PDC2009 day 1 keynote is over and what was the story? Well it is more of a vision thing, but then again this is a PDC not a TechEd so what do you expect. For me the two major themes were

  • Dallas – a centralised data service that allows unified access to both public and private via subscriptions. Thus allowing core data being used for any purpose the user requires within the EULA of the data in question. It will be interesting what will be published in this manner, is there a market for a centralised data clearing house? only time will tell.
  • AppFabric – Basically taking the operating model for the Azure services and allow a company to have a similar model in their own IT system. Thus allowing code to be written that can work on the corporate system or Azure cloud without alteration. This I see as being big.,

So what was not mentioned, well it was mobile. The only comment was a ‘come to Mix in the spring for stuff about the next mobile offering. Whatever is shown there is going to have to very good to address the momentum of the iPhone. I think a good bet is that leveraging the Azure fabric might be important for the mobile offering

We are hosting Microsoft’s Azure Technical Briefing

Interesting in finding out more about Microsoft's Cloud computing strategy and the technology behind Azure? Yes – well you are in luck there are more UK Microsoft road show events in February. They are in Cambridge, Edinburgh and the one we are hosting in Bradford on the 13th.

For more details and links to registration see