In this article I will explain how one can automate their .NET applications development using Azure DevOps. For the sake of this example I created a simple Console Application targeting .NET Framework 6.
The code only includes the below line.
Console.WriteLine("Hello from Azure Devops!");
First things first, a Git repository will be needed for the CI procedure. I chose to use Azure DevOps repositories as it is integrated with Visual studio and can be used very quickly. By pressing Add to Source Control a dialog will appear to choose the organization and project on which the repository will be created. This will create a new repository and you should then commit and push your code to the repository using the UI of Visual Studio.
After the push, the repository will be created on Azure DevOps
I disabled the automatic triggers on the repository with pr and trigger to none and I used the latest ubuntu machine as the build agent.
If a specific version of .NET is required it should be included in the task UseDotNet@2.
The building of the project is done from the DotNetCoreCLI@2 task. It will search everything with the .csproj extension and build it using the Azure CLI.
The last task that I included will run the application from the debug output folder.
trigger: - none pr: none pool: vmImage: ubuntu-latest steps: - task: UseDotNet@2 inputs: version: '6.0.x' includePreviewVersions: true - task: DotNetCoreCLI@2 displayName: Building .NET project inputs: command: 'build' projects: '**/*.csproj' arguments: '--configuration debug' - task: PowerShell@2 inputs: targetType: 'inline' script: | cd "bin/debug/net6.0" ./ConsoleApp1
As my application only Included a print message, this will be shown on the output.
More details on how to build .NET projects with Azure DevOps