Build your ASP.NET Core app

Last Update: 3/17/2017

Team Services | TFS 2017 | TFS 2015 | Previous versions (XAML builds)

ASP.NET Core is a lean and composable framework for building web and cloud applications. Here we'll show you how to define your continuous integration (CI) process.

Get set up

For the instructions in this topic, you need an ASP.NET Core project in Visual Studio 2015 Update 3 or Visual Studio 2017.

TIP

If you don't yet have an app but want to try this out, then see the Q&A below.

Define your CI build process

Create the build definition

  1. Open your team project in your web browser ▼

    Browse to team project

    (If you don't see your team project listed on the home page, select Browse.)

    • On-premises TFS: http://{your_server}:8080/tfs/DefaultCollection/{your_team_project}
    • Visual Studio Team Services: https://{your_account}.visualstudio.com/DefaultCollection/{your_team_project}

    The TFS URL doesn't work for me. How can I get the correct URL?

  2. Create a build definition (Build & Release tab > Builds) ▼

    Build tab

  3. Start with an empty process.
  4. As the repository source, select the team project, repository, and branch.

Add the tasks

Add the following tasks.

icon
Utility: Command Line

Restore NuGet packages.

  • Tool: dotnet
  • Arguments: restore
  • Advanced, Working folder: Folder in which the project.json file (for projects created with VS 2015) or .csproj file (for projects created with VS 2017) exists.
icon
Build: Visual Studio Build

(Optional) Build any additional projects that are checked in.

  • Solution: **\*.sln
  • Platform: $(BuildPlatform)
  • Configuration: $(BuildConfiguration)
  • Visual Studio Version: Select Visual Studio 2015 if your project was created in VS 2015 Update 3. Select Visual Studio 2017 is your project was created in VS 2017.
Command line
Utility: Command Line

Build your ASP.NET Core project and publish the output to a folder.

  • Tool: dotnet
  • Arguments: publish -c $(BuildConfiguration) -o $(Build.ArtifactStagingDirectory)
  • Advanced, Working folder: Folder in which the project.json file (for projects created with VS 2015) or .csproj file (for projects created with VS 2017) exists.
icon
Test: Visual Studio Test

(Optional) Run your tests. See

icon
Utility: Archive Files

Archive the output into a web deploy package.

  • Root folder to archive: $(Build.ArtifactStagingDirectory)
  • Prefix root folder name to archive paths: Unchecked
  • Archive type: zip
  • Artifact file to create: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
icon
Utility: Publish Build Artifacts

Publish the build artifacts to be consumed by a release definition.

  • Path to publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
  • Artifact name: drop
  • Artifact type: Server

Define variables

On the Variables tab, add the following variables:

Name Value
BuildConfiguration release
BuildPlatform any cpu

Enable continuous integration (CI)

On the Triggers tab, enable continuous integration (CI). This tells the system to queue a build whenever someone on your team commits or checks in new code.

Select the default agent queue

Click the Options or General tab.

Visual Studio 2017

For the default agent queue, select Hosted VS2017. If you're using TFS or Team Services with private agents, select the queue connected with a pool that has agents with Visual Studio 2017 installed.

Visual Studio 2015

For the default agent queue, select Hosted. If you're using TFS or Team Services with private agents, select the queue connected with a pool that has agents with Visual Studio 2015 installed.

Queue and test the build

Save the build definition and queue a new build by selecting the Queue new build command.

Once the build is done (after a couple of minutes), click on the build number (such as "Build 332"), click the Artifacts tab, and then Explore to see the zip file produced by the build. This is the web deploy package that your release definition will consume to deploy your app.

Deploy your app

After you've run the build, you're ready to create a release definition to deploy your app to:

Q&A

How do I create an ASP.NET Core solution?

  1. If you are using Visual Studio 2015 Update 3, then install .NET Core 1.0.1 - VS 2015 Tooling Preview 2 or newer. If you are using Visual Studio 2017, then you're all set and can skip to the next step.

  2. In Visual Studio, connect to your team project.

  3. On the Team Explorer home page (Keyboard: Ctrl + 0, H), under Solutions, click New.

  4. Select the Visual C# templates node, the Web sub-node.

  5. Select ASP.NET Core Web Application (.NET Core) and click OK.

  6. Select Web Application from the template list.

  7. Click Change Authentication, select No Authentication, and click OK.

  8. Clear Host in the cloud and click OK.

  9. Commit and push (Git) or check in (TFVC) your code.

I use Team Foundation Server on-premises and I don't see some of these features. Why not?

Some of these features are available only on Visual Studio Team Services and not yet available on-premises. Some features are available on-premises if you have upgraded to the latest version of TFS.