Build ASP.NET apps with .NET Framework
Azure DevOps Services | Azure DevOps Server 2022 - Azure DevOps Server 2019 | TFS 2018
Note
In Microsoft Team Foundation Server (TFS) 2018 and previous versions, build and release pipelines are called definitions, runs are called builds, service connections are called service endpoints, stages are called environments, and jobs are called phases.
Note
This article focuses on building .NET Framework projects with Azure Pipelines. For help with .NET Core projects, see .NET Core.
Create your first pipeline
Are you new to Azure Pipelines? If so, then we recommend you try this section before moving on to other sections.
Get the code
Fork the following repo at GitHub:
Import this repo into your Git repo in Azure DevOps Server 2019:
Import this repo into your Git repo in TFS:
https://github.com/Azure-Samples/app-service-web-dotnet-get-started
The sample app is a Visual Studio solution that uses .NET 4.8.
Sign in to Azure Pipelines
Sign-in to Azure Pipelines. After you sign in, your browser goes to https://dev.azure.com/my-organization-name
and displays your Azure DevOps dashboard.
Within your selected organization, create a project. If you don't have any projects in your organization, you see a Create a project to get started screen. Otherwise, select the New Project button in the upper-right corner of the dashboard.
Note
This scenario works on TFS, but some of the following instructions might not exactly match the version of TFS that you are using. Also, you'll need to set up a self-hosted agent, possibly also installing software. If you are a new user, you might have a better learning experience by trying this procedure out first using a free Azure DevOps organization. Then change the selector in the upper-left corner of this page from Team Foundation Server to Azure DevOps.
After you have the sample code in your own repository, create a pipeline using the instructions in Create your first pipeline and select the ASP.NET template. This automatically adds the tasks required to build the code in the sample repository.
Save the pipeline and queue a build to see it 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 pre-installed 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. This 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 the Visual Studio installed on the agent.
Build multiple configurations
It is often required to build your app in multiple configurations. The following steps extend the example above to build the app on four configurations: [Debug, x86], [Debug, x64], [Release, x86], [Release, x64].
Click the Variables tab and modify these variables:
BuildConfiguration
=debug, release
BuildPlatform
=x86, x64
Select Tasks and click on the agent job to change the options for the job:
- Select Multi-configuration.
- Specify Multipliers:
BuildConfiguration, BuildPlatform
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 download NuGet packages from Azure Artifacts, NuGet.org, or some other external or internal NuGet repository with the NuGet task.
This code restores a solution from a project-scoped feed in the same organization.
# Restore 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'
Feedback
Submit and view feedback for