If you haven’t checked out Visual Studio Online yet, you are missing a lot! I’m in the midst of producing a video series on how to use Visual Studio Online for WintellectNOW. Don’t have a WintellectNOW account? No problem. Enter my promo code PETERSEN-14 and get 2 weeks of unlimited free access.
If you are using Visual Studio Online and have begun to use the hosted build controller, you may be wondering how to grab your build artifacts. Deploying to targets such as an Azure Website is simple. However, there are times when all you want are the raw build artififacts (dll’s, exe’s, html, css and js files, etc). How do you get those?
As it turns out, it is pretty simple!
One of nice new features with Visual Studio Online is the new REST Api.
I’ll leave it to you to sort through the Api reference. The one I want to key on is the Api call to get the list of builds:
GET: https://{account}.visualstudio.com/defaultcollection/_apis/build/builds?api-version=1.0-preview.1
The following is an example
{
"value":[
{
"uri":"vstfs:///Build/Build/36",
"id":36,
"buildNumber":"Test-Build-One_20140902.1",
"url":"https://{account}.visualstudio.com/DefaultCollection/_apis/build/Builds/36",
"startTime":"2014-09-02T12:40:31.583Z",
"finishTime":"2014-09-02T12:42:08.483Z",
"reason":"manual",
"status":"succeeded",
"dropLocation":"#/119161/drop",
"drop":{
"location":"#/119161/drop",
"type":"container",
"url":"https://{account}.visualstudio.com/DefaultCollection/_apis/resources/Containers/119161/drop",
"downloadUrl":"https://{account}.visualstudio.com/DefaultCollection/_apis/resources/Containers/119161/drop?api-version=1.0&$format=zip&downloadFileName=Test-Build-One_20140902.1_drop"
},
"log":{
"type":"container",
"url":"https://{account}.visualstudio.com/DefaultCollection/_apis/resources/Containers/119161/logs",
"downloadUrl":"https://{account}.visualstudio.com/DefaultCollection/_apis/resources/Containers/119161/logs?api-version=1.0&$format=zip&downloadFileName=Test-Build-One_20140902.1_logs"
},
"sourceGetVersion":"LG:(no branch):b792b3c303982b6be3e6105c3e587307fd35381a",
"lastChangedBy":{
"id":"f21f35aa-5c28-462a-91cb-e077e30e0dbd",
"displayName":"Elastic Build ({account})",
"uniqueName":"LOCAL AUTHORITY\\Elastic Build ({account})",
"url":"https://{account}.vssps.visualstudio.com/_apis/Identities/f21f35aa-5c28-462a-91cb-e077e30e0dbd",
"imageUrl":"https://{account}.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=f21f35aa-5c28-462a-91cb-e077e30e0dbd"
},
"retainIndefinitely":false,
"hasDiagnostics":true,
"definition":{
"definitionType":"xaml",
"id":17,
"name":"Test-Build-One",
"url":"https://{account}.visualstudio.com/DefaultCollection/_apis/build/Definitions/17"
},
"queue":{
"queueType":"buildController",
"id":2477,
"name":"Hosted Build Controller",
"url":"https://{account}.visualstudio.com/DefaultCollection/_apis/build/Queues/2477"
},
"requests":[
{
"id":36,
"url":"https://{account}.visualstudio.com/DefaultCollection/_apis/build/Requests/36",
"requestedFor":{
"id":"874bcfb5-80fe-4a9f-ac62-25bb3487769f",
"displayName":"John V. Petersen",
"uniqueName":"{account}@gmail.com",
"url":"https://{account}.vssps.visualstudio.com/_apis/Identities/874bcfb5-80fe-4a9f-ac62-25bb3487769f",
"imageUrl":"https://{account}.visualstudio.com/DefaultCollection/_api/_common/identityImage?id=874bcfb5-80fe-4a9f-ac62-25bb3487769f"
}
}
]
},
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ },
{ }
],
"count":15
}
The item you want to pay attention to is the drop node’s downloadUrl Property:
"drop":{
"location":"#/119161/drop",
"type":"container",
"url":"https://{account}.visualstudio.com/DefaultCollection/_apis/resources/Containers/119161/drop",
"downloadUrl":"https://{account}.visualstudio.com/DefaultCollection/_apis/resources/Containers/119161/drop?api-
version=1.0&$format=zip&downloadFileName=Test-Build-One_20140902.1_drop"
}
If you are already authenticated, entering the downloadUrl into a browser will result in a downloaded zip file that contains your deployment artifacts.
There are alternative ways to authorize – which you can find documented here.
That’s it – Super easy to grab your built application artifacts!