How to Build ASP.NET Core RC2 Code with Visual Studio Team Services

Update: As of June 8, 2016 you no longer have to create your own build agent. dotnet.exe is now on the Hosted build agents

With the release of ASP.NET Core RC2 today I wanted to start building those projects with Visual Studio Team Services.  As of this writing, ASP.NET Core RC2 is not on the hosted build agents.

image

Therefore, to build them you will need to stand up a private build agent.  I explained how to do that on Windows in Build Visual Basic 6.0 Applications with Visual Studio Team Services post. I will assume you have read that post and have a functioning build agent.

The first thing we need to do is add ASP.NET Core RC2 to our build agent.

  1. Remote into the build agent
  2. Download and install the command line tools for ASP.NET Core RC2 from https://www.microsoft.com/net/core#windows

With ASP.NET Core RC2 installed we are going to register it as a capability of this agent.

  1. Open Windows Explorer
  2. Right-click the PC node
  3. Select Properties
  4. Click the Advanced system settings link
  5. Click the Environment Variables… button
  6. Click New… under the System variables section
    Field Value
    Variable name ASP.NET_Core
    Variable value RC2
    Note that demands for build definitions do not support spaces in the names which is why I have _Core.
  7. Click OK
  8. Click OK
  9. Click OK

Restart your agent so it can report ASP.NET Core as a capability.  To confirm the new capability follow these steps:

  1. Log in to Visual Studio Team Services
  2. Click the Manage project gear in the upper right-hand corner of the screen
    image
  3. Click your account name
    image
  4. Click Agent queues tab
  5. Click your agent name
  6. Click the Capabilities tab
  7. Verify ASP.NET Core is listed 
    image

With our build agent ready for ASP.NET Core RC2 projects, we can now create our build.  You can use your agent machine or any other machine with the ASP.NET Core RC2 bits on it.  Open a command prompt and type the following:

dotnet new

That will create two files: program.cs and project.json.  Check those files into Visual Studio Team Services. 

Now to the easy part: creating the build to compile our ASP.NET Core RC2 project.

  1. Click the Build hubimage_thumb4 in Visual Studio Team Services
  2. Click the green plus 
  3. Select the Empty template
  4. Click Next
  5. Select your repository
  6. Check the box for Continuous integration
  7. Select Default agent queue
  8. Click Create

With the build created, we need to add the required tasks.

  1. Click Add build step…
  2. Select the Utility category
  3. Click Add next to the Command Line task
  4. Click Add next to the Command Line task to add a second task
  5. Click Add next to the Copy and Publish Build Artifacts
  6. Click Close 
  7. Select the first Command Line task 
    Field Value
    Tool dotnet
    Arguments restore
  8. Select the Command task
    Field Value
    Tool dotnet
    Arguments build
  9. Select the Copy and Publish Build Artifacts task
    Field Value
    Contents **/*.dll
    Artifact Name drop
    Artifact Type Server
  10. Click General tab
  11. Click Add Demand
    Field Value
    Name ASP.NET Core
    Type equals
    Value RC2

    image
    This makes sure that only the agent that has ASP.NET Core RC2 installed is selected to run this build.
  12. Click Save
  13. Name build
  14. Click OK
  15. Click Queue build…
  16. Click OK

Once the build is done you can browse the artifact to see the DLL produced by the build.

image

You can use this technique to build any language using Visual Studio Team Services.

Comments (2) -

  • Salam ELIAS

    3/19/2019 10:42:10 AM | Reply

    Hi, Donovan
    Sorry to write my comment here as I was nit able to write to you on your webinar "Getting started with Azure DevOps", when I ckicked on the neveloppe above, I was requested to follow on twitter which I dont use.
    Anyway, in the webinar you mentioned that SSDT is a very good tool to use for SQL devops, can you sahre any tutorial or references on this subject? I have Azure DevOps server 2019 and SSDT 2017 and would like to start using it for my pipline in premise, not in azure. Thanks in advance

Pingbacks and trackbacks (2)+

Add comment

Loading