Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in /var/www/rassie.dk/blog.rassie.dk/wp-content/themes/suffusion/functions/media.php on line 666
Setting up Visual Studio Online build.vnext to publish an Azure Cloud Service | Rasmus' Ramblings on IT and other stuff
Jun 232015

I have an Azure Cloud service which consists of web and worker roles. To make it quicker to update the cloud service whenever I’ve made changes to it, I want to deploy it from Visual Studio Online.

I already use VSO for source control for this project, and I have previously used the XAML based build process in VSO. Since I was going to move the project from one Azure account to another (from my play/test account to the business account), I decided to change the build process.

Visual Studio Online build.vnext

The new build system is still in preview and has some rough edges. I have encountered bugs regarding rendering of the build output in the browser and queued builds not starting. However, I still think it is ready for production use.

I’ve previously covered how to install and set up an on-premises build agent.

imageIn Visual Studio Online, the build system is accessed from the BUILD menu. The explorer view on the left has been changed a little, ot it now has Build definitions as well as XAML definitions. The XAML definitions are the old style build “scripts”.

There is no change to what you can do with the XAML build definitions; you can still see them and queue builds as usual. Editing build definitions is done in Visual Studio.

With the new build system, the build definitions are created and edited online in VSO.

A build definition consists of a number of build steps. There are many pre-defined build steps that you can choose from: Visual Studio Build, msbuild, Ant, Maven, Xamarin Test Cloud, and many more.

If the pre-defined build steps don’t suit you, you can run PowerShell, Batch, and Bash shell scripts also. In fact some of the pre-defined build steps are simply PowerShell scripts with parameters that are filled in from the VSO web interface.

Build and publish to Azure

After some trial and error, I finished up with a script like this:


The script builds the solution and runs all tests.

I haven’t actually configured the Publish symbols action, but would do that if this were not a web site, so we could easier debug any exceptions.

The added MSBuild task runs MSBuild with the the Publish build target.


This is a target that is already present in an Azure Cloud Service project. It packs the service into a .cspkg file that can be uploaded to Azure for deployment.

The final step in the build definition is Azure Cloud Serivce Deployment expects a .cspkg as well as the .cscfg file from the cloud service project.


In the Azure Cloud Service Deployment build step youneed to select which Azure subscription to use. The Azure subscriptions that are available need to be configured first by adding Service Connections in the VSO project. The Manage link from the build step settings takes you straight to the Service Connections page.

You need the management certificate and other details from the Azure publishsettings.xml file.

I have configured a variable called AzureDeploymentSlot in the build definition. It is used to let the person starting the build select which deployment slot to use. The build definition variables are referenced using $(variablename) .

In addition to the user defined variables, there is a long list of predefined ones. The user defined and predefined variables can be edited and listed from the build definition’s Variables page:


It took me a few trial runs to get the paths to the .cspkg and .cscfg right, but the VSO build logs are helpful by showing the console output from the build process in almost real-time.

  3 Responses to “Setting up Visual Studio Online build.vnext to publish an Azure Cloud Service”

  1. I’m glad you posted this, because I can’t find an example anywhere else of using the new VSO build system with an Azure worker role. But I’m struggling to get this to work.

    I’ve created the extra MSBuild step, and I’m using these arguments:

    /t:Publish /p:PublishDir=PublishDir\ /p:TargetProfile=Cloud

    I’m using PublishDir so that the paths for the cscfg and cspkg files are simpler. If I manage to get that far, I think they should end up as:


    Although the prompt says “Solution”, I’m providing my ccproj in that field (I can see from your screenshot that you do this too):


    Then I need to supply:

    Platform: AnyCPU
    Configuration: $(config)

    My variable is ‘config’ rather than ‘BuildConfiguration’.

    Without specifying AnyCPU, I got this build error:

    Error : The OutputPath property is not set for project ‘CloudService.ccproj’. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration=’release’ Platform=’any cpu’. You may be seeing this message because you are trying to build a project without a solution file, and have specified a non-default Configuration or Platform that doesn’t exist for this project.

    Note that since we are building a project, this needs to be ‘AnyCPU’, whereas for a solution it would be ‘Any CPU’ (with a space). That’s an age old Microsoft legacy inconsistency.

    The problem I have right now is that the MSBuild step rebuilds all the projects beneath the cloud service project, and I guess things are not set up the same way, because this time they fail. In any case, I don’t want to build them all over again.

    Did you have that problem too?


    • Hi David,
      It doesn’t do a rebuild of the entire solution when running the msbuild steps. It seems to do a build, but since the solution was already built on the agent, it doesn’t do anything. The build/compile part of the msbuild task only takes 2 seconds with my cloud service.

      Afterwards, it proceeds to generate the cspkg file which takes a long time.


  2. I’ve just discovered something I missed before. I was watching the first video on this page just now:


    and at 1:12, he clicks on the Deployment ‘tab’. Then when you choose Azure Cloud Services from that list, you get all the build stages you need with all the settings done for you.

    But I’m still getting an error, so I will have to keep trying.

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>