-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure-pipelines.yml
133 lines (119 loc) · 4.6 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
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
trigger:
tags:
include:
- v*
branches:
include:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
# runtime identifiers (see https://docs.microsoft.com/en-us/dotnet/core/rid-catalog)
targets: 'win-x86,win-x64'
steps:
- task: UseDotNet@2
displayName: 'Use .NET 9.0 SDK'
inputs:
packageType: 'sdk'
version: '9.0.x'
installationPath: '$(Agent.ToolsDirectory)/dotnet'
- task: NuGetToolInstaller@1
displayName: 'Install NuGet'
inputs:
versionSpec: '5.x'
- task: DotNetCoreCLI@2
displayName: 'Install GitVersion'
inputs:
command: 'custom'
custom: 'tool'
arguments: 'install -g gitversion.tool'
- task: DotNetCoreCLI@2
displayName: 'Show GitVersion Version'
inputs:
command: 'custom'
custom: 'gitversion'
arguments: 'version'
- task: DotNetCoreCLI@2
name: 'GitVersion'
displayName: 'Run GitVersion'
inputs:
command: 'custom'
custom: 'gitversion'
arguments: '/output buildserver /updateassemblyinfo src/CommonAssemblyInfo.cs'
- task: DotNetCoreCLI@2
displayName: 'Restore'
inputs:
command: 'restore'
projects: '**/*.csproj'
- powershell: |
$env:DOTNET_CLI_TELEMETRY_OPTOUT = 'true'
dotnet publish `
-c $(buildConfiguration) `
/p:TargetFramework=net9.0
foreach ($target in '$(targets)'.Split(',')) {
dotnet publish `
--configuration $(buildConfiguration) `
--runtime $target `
--self-contained `
/p:TargetFramework=net9.0 `
/p:PublishSingleFile=true
Copy-Item `
-Path "$(Build.SourcesDirectory)/_build/.out/LicenseCollector/AnyCPU.Release/net9.0/$target/publish/" `
-Destination "$(Build.ArtifactStagingDirectory)/standalone/$target" `
-Recurse
}
Copy-Item `
-Path "$(Build.SourcesDirectory)/_build/.out/LicenseCollector/AnyCPU.Release/net9.0/publish/" `
-Destination "$(Build.ArtifactStagingDirectory)/portable" `
-Recurse
displayName: Build
- powershell: |
$ErrorActionPreference = "Stop"
dotnet "$(Build.ArtifactStagingDirectory)/portable/LicenseCollector.dll" `
--SolutionFilePath "LicenseCollector.sln" `
--Configuration "$(buildConfiguration)" `
--Platform "$(buildPlatform)" `
--LicenseTemplatePath "$(Build.SourcesDirectory)/THIRD_PARTY_NOTICES.template" `
"$(Build.SourcesDirectory)/THIRD_PARTY_NOTICES"
displayName: Collect Licenses
- powershell: |
Write-Host "Copying files for portable version..."
Copy-Item README.md "$(Build.ArtifactStagingDirectory)/portable"
Copy-Item LICENSE "$(Build.ArtifactStagingDirectory)/portable"
Copy-Item THIRD_PARTY_NOTICES "$(Build.ArtifactStagingDirectory)/portable"
Remove-Item "$(Build.ArtifactStagingDirectory)/portable/*.pdb"
Compress-Archive -Path "$(Build.ArtifactStagingDirectory)/portable/*" "$(Build.ArtifactStagingDirectory)/LicenseCollector-portable-v$(GitVersion.SemVer).zip"
Remove-Item -Recurse -Force "$(Build.ArtifactStagingDirectory)/portable"
foreach ($target in '$(targets)'.Split(',')) {
Write-Host "Copying files for standalone version (target '$target')..."
Copy-Item README.md "$(Build.ArtifactStagingDirectory)/standalone/$target"
Copy-Item LICENSE "$(Build.ArtifactStagingDirectory)/standalone/$target"
Copy-Item THIRD_PARTY_NOTICES "$(Build.ArtifactStagingDirectory)/standalone/$target"
Remove-Item "$(Build.ArtifactStagingDirectory)/standalone/$target/*.pdb"
Compress-Archive -Path "$(Build.ArtifactStagingDirectory)/standalone/$target/*" "$(Build.ArtifactStagingDirectory)/LicenseCollector-standalone-$target-v$(GitVersion.SemVer).zip"
Remove-Item -Recurse -Force "$(Build.ArtifactStagingDirectory)/standalone/$target"
}
Remove-Item -Recurse -Force "$(Build.ArtifactStagingDirectory)/standalone"
displayName: Create Release Packages
- task: PublishPipelineArtifact@1
displayName: 'Publish Pipeline Artifacts'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifactName: 'Packages'
- task: GitHubRelease@1
displayName: Publish to Github Releases
condition: startsWith(variables['Build.SourceBranch'], 'refs/tags/v')
inputs:
gitHubConnection: 'Github'
repositoryName: '$(Build.Repository.Name)'
action: 'edit'
target: '$(Build.SourceVersion)'
tag: '$(Build.SourceBranchName)'
title: 'Product Release $(GitVersion.SemVer)'
releaseNotesSource: 'inline'
assets: '$(Build.ArtifactStagingDirectory)/**/*.zip'
changeLogCompareToRelease: 'lastFullRelease'
changeLogType: 'commitBased'