-
-
Notifications
You must be signed in to change notification settings - Fork 59
/
azure-pipelines-Nuget.yml
130 lines (116 loc) · 4.24 KB
/
azure-pipelines-Nuget.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
# ASP.NET Core
# Build and test ASP.NET Core projects targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger: none
pr: none
name: 1.0.$(rev:r)
pool:
vmImage: 'ubuntu-latest'
variables:
solution: 'src/Majorsoft.Blazor.Components.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
AssemblyCompany: 'Majorsoft'
AssemblyAuthor: 'Imre Toth'
AssemblyProduct: 'Majorsoft Blazor Components'
AssemblyCopyright: 'Copyright © 2022 Majorsoft'
AssemblyVersion: '${{ parameters.AssemblyVersion }}'
PreviewPackageVersion: '${{ parameters.PreviewPackageVersion }}'
parameters:
- name: AssemblyVersion
displayName: 'Required Nuget package version e.g. "1.0.0"'
type: string
default: ''
- name: PreviewPackageVersion
displayName: 'Optional Preview version e.g. "-rc.2.20479.15"'
type: string
default: ' '
jobs:
- job: BuildAndPublish
displayName: Package Nuget
steps:
- task: UseDotNet@2
displayName: Install .NET 5
inputs:
packageType: 'sdk'
version: '5.0.100' # replace this value with the version that you need for your project
- task: Assembly-Info-NetCore@2
displayName: 'Update Web Assembly Info'
inputs:
Path: '$(Build.SourcesDirectory)'
FileNames: '/src/**/*.csproj'
InsertAttributes: true
FileEncoding: 'auto'
WriteBOM: false
Authors: '$(AssemblyAuthor)'
Company: '$(AssemblyCompany)'
Product: '$(AssemblyProduct)'
Description: 'Blazor Components by Imre Toth'
Copyright: '$(AssemblyCopyright)'
RepositoryType: 'Git'
VersionNumber: '$(AssemblyVersion)'
FileVersionNumber: '$(AssemblyVersion)'
InformationalVersion: '$(AssemblyVersion)'
PackageVersion: '$(AssemblyVersion)'
GeneratePackageOnBuild: false
LogLevel: 'verbose'
FailOnWarning: false
DisableTelemetry: false
- task: DotNetCoreCLI@2
displayName: 'dotnet restore packages'
inputs:
command: 'restore'
projects: '$(solution)'
feedsToUse: 'select'
- task: DotNetCoreCLI@2
displayName: 'dotnet build'
inputs:
command: 'build'
projects: '$(solution)'
arguments: '--configuration $(buildConfiguration)'
- task: DotNetCoreCLI@2
displayName: 'run tests'
inputs:
command: 'test'
projects: '**/*.Tests.csproj'
arguments: '--configuration $(buildConfiguration)'
# - task: DotNetCoreCLI@2
# displayName: 'dotnet pack'
# inputs:
# command: 'pack'
# packagesToPack: 'src/**/*.csproj'
# packDirectory: '$(Build.ArtifactStagingDirectory)/nupkgs'
# nobuild: true
# includesymbols: true
# versioningScheme: 'byEnvVar'
# versionEnvVar: '$(AssemblyVersion)$(PreviewPackageVersion)'
- task: PowerShell@2
displayName: Create Nuget packages
inputs:
targetType: 'inline'
script: |
$version = '$(AssemblyVersion)' + '$(PreviewPackageVersion)'
$config = '$(buildConfiguration)'
$out = '$(Build.ArtifactStagingDirectory)/nupkgs'
Write-Host $version
#$newVersion = "<Version>" + $version + "<`/Version>"
#Write-Host $newVersion
$verRegex = '<Version>.*'
# $nugetRegex = '(<PackageReference\s+Include="Majorsoft\.Blazor\..* Version=")([rc0-9\.-]*)(".*)'
Get-ChildItem -Path src/**/*.csproj | % {
$file = $_.FullName
Write-Host $file
if((Get-Content -path $file -Raw) -match $verRegex) {
dotnet pack $file --configuration $config --output $out -p:PackageVersion=$version
}
#(Get-Content -path $file -Raw) -replace $verRegex, $newVersion | Set-Content -Path $file
#(Get-Content -path $file -Raw) -replace $nugetRegex, "`${1}$version`${3}" | Set-Content -Path $file
}
- task: DotNetCoreCLI@2
displayName: 'dotnet upload Nuget'
inputs:
command: 'push'
packagesToPush: '$(Build.ArtifactStagingDirectory)/nupkgs/*.nupkg'
nuGetFeedType: 'internal'
publishVstsFeed: '4f8b1f2e-37e5-4c51-b721-13f56be6a30d'