Clone the repo and open it in the Visual Studio or Visual Studio Code. Here you can read how to download both.
Right click on the solution node and click on Add -> New Item...
There is no yaml file template yet but just find a text file and rename the extension
Call it f.ex. api-build-pipeline.yaml
Then paste the following code
variables: buildConfiguration: 'Release' steps: - script: dotnet restore displayName: 'dotnet restore' - script: dotnet build --configuration $(buildConfiguration) displayName: 'dotnet build with following configuration $(buildConfiguration)' - script: dotnet test $(Parameters.TestProjects) --configuration $(BuildConfiguration) displayName: 'dotnet test' - task: [email protected] displayName: Publish and zip WebApplication to output inputs: command: publish publishWebProjects: False arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)' zipAfterPublish: True - task: [email protected] displayName: Publish artifacts
This is exactly representation of this
Save everything and push the changes. You can take a look at the complete code here.
Now we are going to create a new build pipeline and use this yaml file.
Navigate to Pipelines -> Builds
Click on + New
Choose New build pipeline
We are hosting code in the Azure DevOps repo that's why choosing Azure Repos Git
Choose your repo, I am using MyVeryFirstAPIWithYaml.
Now we have a couple of choices. Azure DevOps recommends you to use the ASP.NET Core template. We are already created yaml file for our solution, that's why choosing Existing Azure Pipelines YAML file
Now you have to paste in the name of the yaml file we created previously. The dropdown unfortunately doesn't work yet, but I am sure Azure DevOps team will fix it.
Click on Continue.
Now to save your pipeline you have to click on Run. By default the name of the build pipeline become the name of the repo. If you are not agree go to Pipelines->Builds
And click on small folder icon. Click on you build definition and Edit
Now click on dots
And choose either Triggers or Variables.
Click on YAML
Now you can change the Name, the Agent pool and YAML path. It's interesting by default Azure DevOps chose to build our solution using Ubuntu box. If you prefer something else just choose it.
Usually you choose Hosted VS2017 if you kind of used to windows build environment, but with .NET Core it doesn't matter. This is the power of being cross platform.
I will slightly change the name to MyVeryFirstAPIWithYaml-CI. CI means Continuous Integration and means that I want this build triggered each time I push the code.