-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
78 lines (67 loc) · 3.07 KB
/
azure-pipelines.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Documentation for Azure Pipelines : https://docs.microsoft.com/en-us/azure/devops/pipelines/?view=vsts
# Source for Azure Pipeline tasks : https://github.com/Microsoft/azure-pipelines-tasks
#
# Note that documentation and Azure DevOps editor uses different aliases for the commands.
trigger:
- master
pool:
vmImage: 'windows-2019'
variables:
# Disable local caching with nuget restore
# Upon each new build a new machine is provisioned and therefore will not have the cache from before so we can disable caching. This saves around 1 minute on each build.
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
# Build configuration settings
buildConfiguration: 'Release' # 'Release' or 'Debug'
majorVersion: '0'
minorVersion: '4'
patchVersion: '1'
releaseBuildNumber : $(majorVersion).$(minorVersion).$(patchVersion)
steps:
- task: NuGetToolInstaller@0
displayName: 'Install NuGet tools'
- task: DotNetCoreInstaller@0
displayName: 'Install .NET core'
inputs:
version: '2.2.100'
# Based on https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-build?tabs=netcore2x, there is no need to run restore separately
# but do it in a separate step to keep track on the timings
- task: DotNetCoreCLI@2
displayName: 'Restore NuGet packages'
inputs:
command: 'restore'
projects: '**/Tanka.GraphQL.Net.Client.*.csproj'
- task: DotNetCoreCLI@2
displayName: 'Build'
inputs:
command: 'build'
# For some reason task doesn't support 'configuration' option directly even that is in the example but setting that doesn't do anything.
# As a workaround pass configuration as a direct argument and control value as a variable
# TODO retest if the configuration works
arguments: '--configuration $(buildConfiguration)'
projects: '**/Tanka.GraphQL.Net.Client.*.csproj'
- task: VSTest@2
displayName: 'Run unit tests'
inputs:
platform: '$(buildPlatform)'
configuration: '$(buildConfiguration)'
# The build phase should build the nuget file, so I assume that that step can be skipped
- task: DotNetCoreCLI@2
displayName: 'Pack NuGet packages'
inputs:
command: 'pack'
searchPatternPack: '**/Tanka.GraphQL.Net.Client.csproj' # Note: Use '!' instead of the '-:' for negations, documentation is wrong
nobuild: true # The projects are already built in the previous step, so skip build here
configurationToPack: '$(buildConfiguration)'
# versioningScheme : byEnvVar
# versionEnvVar: releaseBuildNumber
versioningScheme : byPrereleaseNumber
requestedMajorVersion: '$(majorVersion)'
requestedMinorVersion: '$(minorVersion)'
requestedPatchVersion: '$(patchVersion)'
outputDir: '$(Build.ArtifactStagingDirectory)/nuget/' # Add 'nuget' folder to the path to be explicit where the files are, helps push command to find the packages
- task: DotNetCoreCLI@2
displayName: 'Push NuGet packages'
inputs:
command: 'push'
searchPatternPush: '$(Build.ArtifactStagingDirectory)/nuget/*.nupkg' # example of a package path 'D:\a\1\a\nuget\Tanka.GraphQL.Net.Client.0.1.1-CI-20190104-231010.nupkg'
feedPublish: '7c355e95-b690-496c-a239-4feb7350bbdd'