'First time Azure DevOps user, tips on what I could do better in my build pipeline

I work for a small company and we are just starting to get our DevOps pipeline setup. The codebase is about 20 projects in a Visual Studio Solution. Some of these projects' frameworks are .Net 5 and others are .Net Framework 4.8. We are currently in the process of updating but for now we need to use what we have. The following is my attempt at a build pipeline. It runs and I think it works. But I wanted to get more professional opinions on what I can do better because I feel like it is pretty newb.

Here is my yml file:

# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core

trigger:
- develop

pool:
  vmImage: 'windows-latest'

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

steps:
- task: NuGetToolInstaller@1
  displayName: 'Install NuGet'

- task: NuGetCommand@2
  displayName: 'NuGet restore'
  inputs:
    command: 'restore'
    restoreSolution: '$(solution)'
    feedsToUse: 'select'
    vstsFeed: '6010f35a-7ea3-4aa2-8264-60e3a5f02e6f'

- task: UseDotNet@2
  displayName: 'Use .NET Core sdk 5.0.404'
  inputs:
    packageType: 'sdk'
    version: '5.0.404'
    includePreviewVersions: true

#Using DotNet and NuGet restore because without doing both the build breaks.
- task: DotNetCoreCLI@2
  displayName: 'DotNet Restore'
  inputs:
    command: 'restore'
    projects: '**/*.csproj'
    feedsToUse: 'select'
    vstsFeed: '6010f35a-7ea3-4aa2-8264-60e3a5f02e6f'

#Specifying older version to work with our older project dependencies.
- task: NodeTool@0
  displayName: 'Use Node version 14.x'
  inputs:
    versionSpec: '14.x'

#The CleanWebsitesPackage lines are weird, I added them because the build was deleting most of the .Net Framework 4.8 project outputs
#when I looked in the logs it showed these steps were the ones doing the deleting. 
#By pointing them at nothing it doesn't delete.
- task: VSBuild@1
  displayName: 'VS Build'
  inputs:
    solution: '$(solution)'
    msbuildArgs: '
    /p:DeployOnBuild=true 
    /p:WebPublishMethod=package 
    /p:PackageAsSingleFile=true 
    /p:SkipInvalidConfigurations=true 
    /p:DesktopBuildPackageLocation="$(build.artifactStagingDirectory)\WebApp.zip" 
    /p:DeployIisAppPath="Default Web Site"
    /p:CleanWebsitesPackageCoreDependsOn=""
    /p:CleanWebsitesPackageDependsOn=""'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: ExtractFiles@1
  inputs:
    archiveFilePatterns: '$(build.artifactStagingDirectory)\WebApp.zip'
    destinationFolder: '$(build.artifactStagingDirectory)\WebApp'
    cleanDestinationFolder: true
    overwriteExistingFiles: true

- task: DeleteFiles@1
  inputs:
    SourceFolder: 
    Contents: '(build.artifactStagingDirectory)\WebApp.zip'
    
- task: PublishPipelineArtifact@1
  inputs:
    targetPath: '$(build.artifactStagingDirectory)'
#    targetPath: '$(Pipeline.Workspace)' #Uncomment to publish entire directory
    artifact: 'drop'
    publishLocation: 'pipeline'


Solution 1:[1]

I would probably keep things simple but here are few suggestions i can think off.

  1. If the scope of this pipeline is to become a multi-stage pipeline in the future then you could utilize stages to define multiple stages of your pipeline

stages:

  • stage: A jobs:

    • job: A1
    • job: A2
  • stage: B jobs:

    • job: B1
    • job: B2

Reference: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/stages?view=azure-devops&tabs=yaml

  1. You can use templates to define reusable content, logic, and parameters.

Reference: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/templates?view=azure-devops

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ia1