forked from Kros-sk/Kros.AspNetCore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.yml
116 lines (99 loc) · 4.07 KB
/
build.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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
trigger:
tags:
include:
- 'appinsights-v*'
- 'aspnetcore-v*'
- 'masstransitaz-v*'
- 'mediatr-v*'
- 'problemdetails-v*'
- 'swagger-v*'
pool: Default
workspace:
clean: outputs
resources:
repositories:
- repository: templates
type: git
name: DevShared/Templates
variables:
- group: Nuget
- name: buildConfiguration
value: 'Release'
- name: project.AppInsights
value: 'Kros.ApplicationInsights.Extensions'
- name: project.AspNetCore
value: 'Kros.AspNetCore'
- name: project.MassTransitAzure
value: 'Kros.MassTransit.AzureServiceBus'
- name: project.MediatR
value: 'Kros.MediatR.Extensions'
- name: project.ProblemDetails
value: 'Kros.ProblemDetails.Extensions'
- name: project.Swagger
value: 'Kros.Swagger.Extensions'
- name: 'project.Current'
value: ''
- name: 'project.TestProjectsCount'
value: 0
steps:
- powershell: echo '##vso[task.setvariable variable=project.Current]$(project.AppInsights)'
displayName: 'Set project: $(project.AppInsights)'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/appinsights-v')
- powershell: echo '##vso[task.setvariable variable=project.Current]$(project.AspNetCore)'
displayName: 'Set project: $(project.AspNetCore)'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/aspnetcore-v')
- powershell: echo '##vso[task.setvariable variable=project.Current]$(project.MassTransitAzure)'
displayName: 'Set project: $(project.MassTransitAzure)'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/masstransitaz-v')
- powershell: echo '##vso[task.setvariable variable=project.Current]$(project.MediatR)'
displayName: 'Set project: $(project.MediatR)'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/mediatr-v')
- powershell: echo '##vso[task.setvariable variable=project.Current]$(project.ProblemDetails)'
displayName: 'Set project: $(project.ProblemDetails)'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/problemdetails-v')
- powershell: echo '##vso[task.setvariable variable=project.Current]$(project.Swagger)'
displayName: 'Set project: $(project.Swagger)'
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/swagger-v')
- script: |
echo No project was specified.
echo Build must be triggered with correct tag and based on the tag name, the project is selected.
echo Available tag names and their projects:
echo - appinsights-v* - Kros.ApplicationInsights.Extensions
echo - aspnetcore-v* - Kros.AspNetCore
echo - masstransitaz-v* - Kros.MassTransit.AzureServiceBus
echo - mediatr-v* - Kros.MediatR.Extensions
echo - problemdetails-v* - Kros.ProblemDetails.Extensions
echo - swagger-v* - Kros.Swagger.Extensions
exit 1
displayName: 'Check project name'
condition: eq(variables['project.Current'], '')
- template: steps/delete-nupkgs.yml@templates
- task: DotNetCoreCLI@2
displayName: 'Build'
inputs:
command: build
projects: '**/*.csproj'
arguments: '--configuration $(BuildConfiguration)'
- powershell: |
$count = 0
Get-ChildItem -Path "$env:System_DefaultWorkingDirectory" -Filter "$(project.Current)*test*.csproj" -Recurse -File | ForEach-Object {
$count = $count + 1
}
Write-Host Test projects found: $count
Write-Output ("##vso[task.setvariable variable=project.TestProjectsCount;]$count")
displayName: Find Test Projects
- template: steps/dotnet-test-and-publish-results.yml@templates
parameters:
buildConfiguration: '$(BuildConfiguration)'
- task: CopyFiles@2
displayName: 'Copy package files to staging directory'
inputs:
Contents: |
**/$(project.current)*.nupkg
**/$(project.current)*.snupkg
TargetFolder: '$(build.artifactStagingDirectory)'
FlattenFolders: true
- template: steps/nuget-push.yml@templates
parameters:
feed: '$(nuget.feed)'
packages: '$(Build.ArtifactStagingDirectory)/$(project.Current)*.nupkg'