9
9
- rel/*
10
10
11
11
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
13
18
14
19
jobs :
15
20
- job : BuildBits
21
+ displayName : Build and Test solution
16
22
timeoutInMinutes : 60
17
23
steps :
18
24
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
28
28
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)
30
34
31
35
# Install the .NET 7 SDK
32
36
- task : UseDotNet@2
33
37
displayName : Install the .NET 7 SDK
34
38
inputs :
35
- version : 7.0.x
39
+ version : $(DotNet.Version)
36
40
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
51
42
52
43
# Set Build Version
53
44
- script : nbgv cloud
@@ -57,42 +48,48 @@ jobs:
57
48
- pwsh : build/Update-Headers.ps1 -Verify
58
49
displayName : Verify headers
59
50
51
+ # Restore solution
52
+ - script : dotnet restore -p:Configuration=$(Build.Configuration)
53
+ displayName : Restore solution
54
+
60
55
# Build solution
61
- - script : dotnet build -c Release
56
+ - script : dotnet build --no-restore -c $(Build.Configuration)
62
57
displayName : Build solution
63
58
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"
66
63
displayName : Run .NET 6 unit tests
67
64
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"
70
67
displayName : Run .NET Core 3.1 unit tests
71
68
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"
74
71
displayName : Run .NET Framework 4.7.2 unit tests
75
72
76
73
# Publish test results
77
74
- task : PublishTestResults@2
78
75
displayName : Publish test results
79
76
inputs :
80
- testResultsFormat : ' VSTest'
81
- testResultsFiles : ' **/VSTestResults*.trx'
77
+ testResultsFormat : VSTest
78
+ testResultsFiles : ' **/TestResults/ VSTestResults*.trx'
82
79
condition : always()
83
80
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
87
84
88
- # Sign package(s)
85
+ # Sign packages
89
86
- pwsh : build/Sign-Package.ps1
90
87
displayName : Authenticode sign packages
91
88
env :
92
89
SignClientUser : $(SignClientUser)
93
90
SignClientSecret : $(SignClientSecret)
94
91
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 '], ''))
96
93
97
94
# Publish build artifacts
98
95
- publish : bin/nupkg
0 commit comments