Some time ago a new tab appeared in visual studio online called Build.Preview. For the project we are working on we use the VSO build system so it caught my attention. In our team we were running into some difficulties using continuous deployment of Azure WebApps with WebJobs. Also we didn’t like the way we were automatically pushing out nuget packages to our private MyGet feed. We created all sorts of scripts and custom templates, but it just seemend too complicated. Why should a build environment be harder to configure or debug than a local msbuild command?
Microsoft had pushed out the customizable cross platform build system that I was waiting for!
- The build task is nothing more than msbuild.exe in a concole, and you get the output directly while running.
- You can add a ‘deploy to Azure WebApps’ step to your build.
- Adding a powershell script as a build step (and just about anything else that exists in the world!)
- Debugging a build is simple, you can execute it on your local machine.
Let’s build and deploy an Azure WebApp with some webjobs
In visual studio online I clicked the big green plus button got a dialog with two tabs named build and deployment. I chose the deployment tab, selected Azure Website and pushed the ‘ok’ button.
This looks simple, a lot of stuff is already filled in. Under repository I changed the mappings so that only the right solution targeted for the build. I also set the configuration property because there are some transforms in my project. Under Triggers you can set up continuous integration for the build.
Next up, Azure Web Site Deployment. The line is red, it’s probably expecting some wisdom from me.
First I selected my azure subscription that was already linked to visual studio online. After this I tried to select my target WebApp but the select box remained empty… Hmm, this doesn’t work, but wait I can type in there too. So next I filled in the name of my WebApp. (Not the full domain, just the name without .azurewebsites.net)
Saved it, named it and queued it!
I started the build in the hosted controller and got a cool powershell looking console. It started running and all was looking great until it got to the publish step.
##[error]Found more than one file to deploy with search pattern 'C:\a\a918231f\staging\**\*.zip'. There can be only one
Thinking about the error “More than one file to deploy” and smiling because of the highlander/mcloud joke in there. I got it, in the package property “*.zip” was defined by default. The default msbuild arguments “/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true” are responsible for creating this package on build.
Normally this would work but I’ve got some webjobs in my solution and it also creates packages for these. All the webjobs are also packed in the website package so I changed “*.zip” to a specific “mywebsiteprojectname.zip”.
Next build and deploy was succesful!