Build ASP.NET apps with .NET Framework

Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019

This article describes how to build a .NET Framework project with Azure Pipelines. For .NET Core projects, see Build, test, and deploy .NET Core apps.

Create an Azure DevOps project

  1. In your Azure DevOps organization or collection, select New project or Create project.
  2. Enter a Project name.
  3. Select the Visibility for your project.
  4. Select Create.

Get the sample app

The sample app is a Visual Studio solution that uses .NET 4.8. To get the app, fork the GitHub repo at https://github.com/Azure-Samples/app-service-web-dotnet-get-started.

Create and build the pipeline

Once you have the sample code in your own repository, create a pipeline in your Azure DevOps project by using the instructions in Create your first pipeline.

Select the ASP.NET template. This choice automatically adds the tasks required to build the code in the sample repository.

Select Save and run to see the pipeline in action.

Build environment

You can use Azure Pipelines to build your .NET Framework projects without needing to set up any infrastructure of your own. The Microsoft-hosted agents in Azure Pipelines have several released versions of Visual Studio preinstalled to help you build your projects. Use windows-2022 for Windows Server 2022 with Visual Studio 2022.

You can also use a self-hosted agent to run your builds. Using a self-hosted agent is helpful if you have a large repository and you want to avoid downloading the source code to a fresh machine for every build.

Your builds run on a self-hosted agent. Make sure that you have the necessary version of Visual Studio installed on the agent.

Build multiple configurations

You might need to build your app in multiple configurations. The following steps build the example app on four configurations: Debug, x86, Debug, x64, Release, x86, and Release, x64.

  1. In the pipeline UI, select the Variables tab and modify the following variables:

    • BuildConfiguration = debug, release
    • BuildPlatform = x86, x64
  2. Select Tasks and then select agent job to change the following options for the job:

    • Select Multi-configuration.
    • Specify Multipliers: BuildConfiguration, BuildPlatform
  3. Select Parallel if you have multiple build agents and want to build your configuration/platform pairings in parallel.

Restore dependencies

You can use the NuGet task to install and update NuGet package dependencies. You can also use the NuGet task to download NuGet packages from Azure Artifacts, NuGet.org, or other external or internal NuGet repositories.

The following example restores a solution from a project-scoped feed in the same organization.

- task: NuGetCommand@2
  inputs:
    command: 'restore'
    feedsToUse: 'select'
    vstsFeed: 'my-project/my-project-scoped-feed'
    includeNuGetOrg: false
    restoreSolution: '**/*.sln'