Sponsored By Aspose - File Format APIs for .NET

Aspose are the market leader of .NET APIs for file business formats – natively work with DOCX, XLSX, PPT, PDF, MSG, MPP, images formats and many more!

Quick easy steps to grab your build artifacts from Visual Studio Online

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!

About johnvpetersen

I've been developing software for 20 years, starting with dBase, Clipper and FoxBase + thereafter, migrating to FoxPro and Visual FoxPro and Visual Basic. Other areas of concentration include Oracle and SQL Server - versions 6-2008. From 1995 to 2001, I was a Microsoft Visual FoxPro MVP. Today, my emphasis is on ASP MVC .NET applications. I am a current Microsoft ASP .NET MVP. Publishing In 1999, I wrote the definitive whitepaper on ADO for VFP Developers. In 2002, I wrote the Absolute Beginner’s Guide to Databases for Que Publishing. I was a co-author of Visual FoxPro Enterprise Development from Prima Publishing with Rod Paddock, Ron Talmadge and Eric Ranft. I was also a co-author of Visual Basic Web Development from Prima Publishing with Rod Paddock and Richard Campbell. Education - B.S Business Administration – Mansfield University - M.B.A. – Information Systems – Saint Joseph’s University - J.D. – Rutgers University School of Law (Camden) In 2004, I graduated from the Rutgers University School of Law with a Juris Doctor Degree. I passed the Pennsylvania and New Jersey Bar exams and was in private practice for several years – concentrating transactional and general business law (contracts, copyrights, trademarks, independent contractor agreements, NDA’s, intellectual property and mergers and acquisitions.).
This entry was posted in Uncategorized, Visual Studio Online. Bookmark the permalink. Follow any comments here with the RSS feed for this post.