Skip to content

Latest commit

 

History

History
128 lines (98 loc) · 4.17 KB

4.set-up-a-build-pipeline-in-azuredevops.md

File metadata and controls

128 lines (98 loc) · 4.17 KB

4. Set up a Build pipeline in AzureDevops

  • Open the AzureDevops page and click on the Sign in to Azure Devops link.
  • Click on New organization and follow the steps to create a new organization. Name it [YourAppName]org.
  • Enter [YourAppName]Proj as project name in the Create a project to get started window.
  • Select Public visibility and click the Create project button.
  • Click on the Pipelines tab to continue.
  • Click on the Create Pipeline button.
  • Select GitHub in the Where is your code window?

Where is your code window?

  • Select your GitHub [YourAppName]repo.

  • Click on Approve and install in the Repository access section in the Azure Pipelines window.

  • You get redirected to the Configure your pipeline window. Select ASP.NET Core (.NET Framework)

  • You get redirected to the Review your pipeline YAML window. Click Save and run

Review your pipeline YAML?

  • Click Save and run in (commit directly to the main branch checked) the Save and run window
  • The pipeline should start running.

ATTENTION:

It is possible the BUILD will fails with this error message. You can read more about No hosted parallelism has been purchased or granted on StackOverflow

    1 error(s), 0 warning(s)
    No hosted parallelism has been purchased or granted. To request a free parallelism grant, please fill out the following form https://aka.ms/azpipelines-parallelism-request
  • When te pipeline has finished, you can see the VSTest@2 task as throws an error.
  • Open a command prompt in the root of your project and pull the changes from the GitHub repository. Git pull will get you the azure-pipelines.yml file in the root of your project.
    git pull
  • In your project Replace the content of the azure-pipelines.yml with the tasks below
trigger:
- main

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: UseDotNet@2
    displayName: 'Use latest .NET9'
    inputs:
      version: 9.0.x
      includePreviewVersions: true

- task: NuGetToolInstaller@1
  displayName: Install Nuget Tool

- task: UseNode@1
  displayName: Install NodeJs
  inputs:
    versionSpec: '20.x'
    checkLatest: true

- task: NuGetCommand@2
  displayName: Restore nuget packages
  inputs:
    restoreSolution: '$(solution)'

- task: CmdLine@2
  displayName: Install new ABP CLI
  inputs:
    script: dotnet tool install -g Volo.Abp.Studio.Cli || dotnet tool update -g Volo.Abp.Studio.Cli

- task: CmdLine@2
  displayName: Run abp install-libs command
  inputs:
    script: abp install-libs

- task: DotNetCoreCLI@2
  displayName: 'Dotnet build projects'
  inputs:
    command: build
    projects: '**/src/*/*.csproj'
    arguments: '--configuration $(buildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: Run unit tests
  inputs:
    command: test
    projects: '**/*[Tt]ests/*.csproj'
    arguments: '--configuration $(BuildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: Dotnet publish
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
    zipAfterPublish: True

- task: PublishBuildArtifacts@1
  displayName: Publish artifact
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
  condition: succeededOrFailed()
  • Open a terminal in the root folder of your project and push your changes to your GitHub repo.
    git add .
    git commit -m EndPart4
    git push
  • Pushing the changes to your GitHub repo triggers a new run of the build pipeline.
  • After a successful build, you can see in the Summary window 1 published to the drop folder.

Summary after a successful build

[Previous] - [Next]