Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
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.
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
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 azure-pipelines.yml file with the tasks required to build the code to the sample repository. The template includes the VSTest@2 task to run tests. The sample repository doesn't contain tests, so you can remove the VSTest@2 task from the pipeline.
Your pipeline should look like the following example:
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- main
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
# ASP.NET
# Build and test ASP.NET projects.
# Add steps that publish symbols, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/apps/aspnet/build-aspnet-4
trigger:
- main
pool:
name: default
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
steps:
- task: NuGetToolInstaller@1
- task: NuGetCommand@2
inputs:
restoreSolution: '$(solution)'
- task: VSBuild@1
inputs:
solution: '$(solution)'
msbuildArgs: '/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"'
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
Select Save and run and select Jobs to see the pipeline in action.
To publish the build artifacts, add the following task to the end of your YAML file:
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(Pipeline.Workspace)'
artifact: 'myartifact'
publishLocation: 'pipeline'
- task: PublishBuildArtifacts@1
inputs:
pathToPublish: '$(Build.ArtifactStagingDirectory)'
artifactName: drop
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.
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
.
In the pipeline UI, select the Variables tab and modify the following variables:
BuildConfiguration
= debug, release
BuildPlatform
= x86, x64
Select Tasks and then select agent job to change the following options for the job:
BuildConfiguration, BuildPlatform
Select Parallel if you have multiple build agents and want to build your configuration/platform pairings in parallel.
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'
Note
If you're using Ubuntu 24.04 or higher, you must use the NuGetAuthenticate
task with the .NET CLI instead of the NuGetCommand@2
task. See Support for newer Ubuntu hosted images for more details.
Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Learning path
Build applications with Azure DevOps learning path - Training
In this learning path, find out how to collaborate with others to continuously build, test, and verify your applications using Azure Pipelines and GitHub.
Certification
Microsoft Certified: Azure Developer Associate - Certifications
Build end-to-end solutions in Microsoft Azure to create Azure Functions, implement and manage web apps, develop solutions utilizing Azure storage, and more.
Documentation
Build, test, and deploy .NET Core apps - Azure Pipelines
Use .NET Core to build apps with Azure Pipelines.
VSBuild@1 - Visual Studio build v1 task
Build with MSBuild and set the Visual Studio version property.
DotNetCoreCLI@2 - .NET Core v2 task
Build, test, package, or publish a .NET application, or run a custom .NET CLI command.