1
- # Gets the version suffix from the repo tag
2
- # example: v1.0.0-preview1-final => preview1-final
3
- function Get-Version-Suffix-From-Tag {
4
- $tag = $env: APPVEYOR_REPO_TAG_NAME
5
- $split = $tag -split " -"
6
- $suffix = $split [1 .. 2 ]
7
- $final = $suffix -join " -"
8
- return $final
9
- }
10
-
11
1
function CheckLastExitCode {
12
2
param ([int []]$SuccessCodes = @ (0 ), [scriptblock ]$CleanupScript = $null )
13
3
14
4
if ($SuccessCodes -notcontains $LastExitCode ) {
15
- $msg = " EXE RETURNED EXIT CODE $LastExitCode "
16
- throw $msg
5
+ throw " Executable returned exit code $LastExitCode "
17
6
}
18
7
}
19
8
@@ -65,7 +54,9 @@ function RunCleanupCode {
65
54
66
55
function ReportCodeCoverage {
67
56
if ($env: APPVEYOR ) {
68
- dotnet codecov -f " **\coverage.cobertura.xml"
57
+ if ($IsWindows ) {
58
+ dotnet codecov -f " **\coverage.cobertura.xml"
59
+ }
69
60
}
70
61
else {
71
62
dotnet reportgenerator - reports:** \coverage.cobertura.xml - targetdir:artifacts\coverage
@@ -74,8 +65,34 @@ function ReportCodeCoverage {
74
65
CheckLastExitCode
75
66
}
76
67
77
- $revision = @ { $true = $env: APPVEYOR_BUILD_NUMBER ; $false = 1 }[$env: APPVEYOR_BUILD_NUMBER -ne $NULL ];
78
- $revision = " {0:D4}" -f [convert ]::ToInt32($revision , 10 )
68
+ function CreateNuGetPackage {
69
+ if ($env: APPVEYOR_REPO_TAG -eq $true ) {
70
+ # Get the version suffix from the repo tag. Example: v1.0.0-preview1-final => preview1-final
71
+ $tag = $env: APPVEYOR_REPO_TAG_NAME
72
+ $segments = $tag -split " -"
73
+ $suffixSegments = $segments [1 .. 2 ]
74
+ $versionSuffix = $suffixSegments -join " -"
75
+ }
76
+ else {
77
+ # Get the version suffix from the auto-incrementing build number. Example: "123" => "pre-0123".
78
+ if ($env: APPVEYOR_BUILD_NUMBER ) {
79
+ $revision = " {0:D4}" -f [convert ]::ToInt32($env: APPVEYOR_BUILD_NUMBER , 10 )
80
+ $versionSuffix = " pre-$revision "
81
+ }
82
+ else {
83
+ $versionSuffix = " pre-0001"
84
+ }
85
+ }
86
+
87
+ if ([string ]::IsNullOrWhitespace($versionSuffix )) {
88
+ dotnet pack .\src\JsonApiDotNetCore - c Release - o .\artifacts
89
+ }
90
+ else {
91
+ dotnet pack .\src\JsonApiDotNetCore - c Release - o .\artifacts -- version- suffix= $versionSuffix
92
+ }
93
+
94
+ CheckLastExitCode
95
+ }
79
96
80
97
dotnet tool restore
81
98
CheckLastExitCode
@@ -91,27 +108,4 @@ CheckLastExitCode
91
108
92
109
ReportCodeCoverage
93
110
94
- Write-Output " APPVEYOR_REPO_TAG: $env: APPVEYOR_REPO_TAG "
95
-
96
- if ($env: APPVEYOR_REPO_TAG -eq $true ) {
97
- $revision = Get-Version - Suffix- From- Tag
98
- Write-Output " VERSION-SUFFIX: $revision "
99
-
100
- if ([string ]::IsNullOrWhitespace($revision )) {
101
- Write-Output " RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts"
102
- dotnet pack .\src\JsonApiDotNetCore - c Release - o .\artifacts
103
- CheckLastExitCode
104
- }
105
- else {
106
- Write-Output " RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision "
107
- dotnet pack .\src\JsonApiDotNetCore - c Release - o .\artifacts -- version- suffix= $revision
108
- CheckLastExitCode
109
- }
110
- }
111
- else {
112
- $packageVersionSuffix = " pre-$revision "
113
- Write-Output " VERSION-SUFFIX: $packageVersionSuffix "
114
- Write-Output " RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$packageVersionSuffix "
115
- dotnet pack .\src\JsonApiDotNetCore - c Release - o .\artifacts -- version- suffix= $packageVersionSuffix
116
- CheckLastExitCode
117
- }
111
+ CreateNuGetPackage
0 commit comments