Skip to content

Commit bdf9138

Browse files
authored
Merge pull request #450 from Nirmal4G/feature/improve-azp-perf
Improve Perf for Azure Pipelines build
2 parents 982debb + 9b1ebda commit bdf9138

File tree

1 file changed

+37
-40
lines changed

1 file changed

+37
-40
lines changed

azure-pipelines.yml

Lines changed: 37 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,36 @@ pr:
99
- rel/*
1010

1111
pool:
12-
vmImage: windows-2022
12+
vmImage: windows-latest
13+
14+
variables:
15+
Build.Configuration: Release
16+
DotNet.Tools: $(Agent.ToolsDirectory)/dotnet
17+
DotNet.Version: 7.0.x
1318

1419
jobs:
1520
- job: BuildBits
21+
displayName: Build and Test solution
1622
timeoutInMinutes: 60
1723
steps:
1824

19-
# Install the .NET Core 3.1 SDK
20-
- task: UseDotNet@2
21-
displayName: Install the .NET Core 3.1 SDK
22-
inputs:
23-
version: 3.1.x
24-
25-
# Install the .NET 6 SDK
26-
- task: UseDotNet@2
27-
displayName: Install the .NET 6 SDK
25+
# Cache .NET SDKs and Tools across pipeline runs
26+
- task: Cache@2
27+
displayName: Cache .NET SDKs
2828
inputs:
29-
version: 6.0.x
29+
key: 'dotnet | "$(Agent.OS)" | "$(DotNet.Version)"'
30+
restoreKeys: |
31+
dotnet | "$(Agent.OS)"
32+
dotnet
33+
path: $(DotNet.Tools)
3034

3135
# Install the .NET 7 SDK
3236
- task: UseDotNet@2
3337
displayName: Install the .NET 7 SDK
3438
inputs:
35-
version: 7.0.x
39+
version: $(DotNet.Version)
3640
includePreviewVersions: true
37-
38-
# Install NuGet
39-
- task: NuGetToolInstaller@0
40-
displayName: Install NuGet 6.0
41-
inputs:
42-
versionSpec: 6.0.0
43-
44-
# Install NerdBank GitVersioning
45-
- task: DotNetCoreCLI@2
46-
displayName: Install NBGV tool
47-
inputs:
48-
command: custom
49-
custom: tool
50-
arguments: update -g nbgv
41+
performMultiLevelLookup: true
5142

5243
# Set Build Version
5344
- script: nbgv cloud
@@ -57,42 +48,48 @@ jobs:
5748
- pwsh: build/Update-Headers.ps1 -Verify
5849
displayName: Verify headers
5950

51+
# Restore solution
52+
- script: dotnet restore -p:Configuration=$(Build.Configuration)
53+
displayName: Restore solution
54+
6055
# Build solution
61-
- script: dotnet build -c Release
56+
- script: dotnet build --no-restore -c $(Build.Configuration)
6257
displayName: Build solution
6358

64-
# Run .NET 6 tests
65-
- script: dotnet test -c Release -f net6.0 -l "trx;LogFileName=VSTestResults_net6.0.trx"
59+
# Test solution #
60+
61+
# Run .NET 6 unit tests
62+
- script: dotnet test --no-build -c $(Build.Configuration) -f net6.0 -l "trx;LogFileName=VSTestResults_net6.0.trx"
6663
displayName: Run .NET 6 unit tests
6764

68-
# Run .NET Core 3.1 tests
69-
- script: dotnet test -c Release -f netcoreapp3.1 -l "trx;LogFileName=VSTestResults_netcoreapp3.1.trx"
65+
# Run .NET Core 3.1 unit tests
66+
- script: dotnet test --no-build -c $(Build.Configuration) -f netcoreapp3.1 -l "trx;LogFileName=VSTestResults_netcoreapp3.1.trx"
7067
displayName: Run .NET Core 3.1 unit tests
7168

72-
# Run .NET Framework 4.7.2 tests
73-
- script: dotnet test -c Release -f net472 -l "trx;LogFileName=VSTestResults_net472.trx"
69+
# Run .NET Framework 4.7.2 unit tests
70+
- script: dotnet test --no-build -c $(Build.Configuration) -f net472 -l "trx;LogFileName=VSTestResults_net472.trx"
7471
displayName: Run .NET Framework 4.7.2 unit tests
7572

7673
# Publish test results
7774
- task: PublishTestResults@2
7875
displayName: Publish test results
7976
inputs:
80-
testResultsFormat: 'VSTest'
81-
testResultsFiles: '**/VSTestResults*.trx'
77+
testResultsFormat: VSTest
78+
testResultsFiles: '**/TestResults/VSTestResults*.trx'
8279
condition: always()
8380

84-
# Create the NuGet package(s)
85-
- script: dotnet pack -c Release
86-
displayName: Create NuGet package(s)
81+
# Pack solution
82+
- script: dotnet pack --no-build -c $(Build.Configuration)
83+
displayName: Pack solution
8784

88-
# Sign package(s)
85+
# Sign packages
8986
- pwsh: build/Sign-Package.ps1
9087
displayName: Authenticode sign packages
9188
env:
9289
SignClientUser: $(SignClientUser)
9390
SignClientSecret: $(SignClientSecret)
9491
ArtifactDirectory: bin/nupkg
95-
condition: and(succeeded(), not(eq(variables['Build.Reason'], 'PullRequest')), not(eq(variables['SignClientSecret'], '')), not(eq(variables['SignClientUser'], '')))
92+
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'), ne(variables['SignClientUser'], ''), ne(variables['SignClientSecret'], ''))
9693

9794
# Publish build artifacts
9895
- publish: bin/nupkg

0 commit comments

Comments
 (0)