@@ -65,39 +65,28 @@ function ReportCodeCoverage {
65
65
CheckLastExitCode
66
66
}
67
67
68
- # Gets the version suffix from the repo tag
69
- # example: v1.0.0-preview1-final => preview1-final
70
- function GetVersionSuffixFromTag {
71
- $tag = $env: APPVEYOR_REPO_TAG_NAME
72
- $split = $tag -split " -"
73
- $suffix = $split [1 .. 2 ]
74
- $final = $suffix -join " -"
75
- return $final
76
- }
77
-
78
68
function CreateNuGetPackage {
79
69
if ($env: APPVEYOR_REPO_TAG -eq $true ) {
80
- $revision = GetVersionSuffixFromTag
81
- Write-Output " APPVEYOR_REPO_TAG: $env: APPVEYOR_REPO_TAG "
82
- Write-Output " VERSION-SUFFIX: $revision "
83
-
84
- if ([string ]::IsNullOrWhitespace($revision )) {
85
- Write-Output " RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts"
86
- dotnet pack .\src\JsonApiDotNetCore - c Release - o .\artifacts
87
- }
88
- else {
89
- Write-Output " RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$revision "
90
- dotnet pack .\src\JsonApiDotNetCore - c Release - o .\artifacts -- version- suffix= $revision
91
- }
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 " -"
92
75
}
93
76
else {
77
+ # Get the version suffix from the build number, defaulting to 1 for non-cibuilds.
94
78
$revision = @ { $true = $env: APPVEYOR_BUILD_NUMBER ; $false = 1 }[$env: APPVEYOR_BUILD_NUMBER -ne $NULL ];
95
79
$revision = " {0:D4}" -f [convert ]::ToInt32($revision , 10 )
80
+ $versionSuffix = " pre-$revision "
81
+ }
96
82
97
- $packageVersionSuffix = " pre-$revision "
98
- Write-Output " VERSION-SUFFIX: $packageVersionSuffix "
99
- Write-Output " RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$packageVersionSuffix "
100
- dotnet pack .\src\JsonApiDotNetCore - c Release - o .\artifacts -- version- suffix= $packageVersionSuffix
83
+ if ([string ]::IsNullOrWhitespace($versionSuffix )) {
84
+ Write-Output " RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts"
85
+ dotnet pack .\src\JsonApiDotNetCore - c Release - o .\artifacts
86
+ }
87
+ else {
88
+ Write-Output " RUNNING dotnet pack .\src\JsonApiDotNetCore -c Release -o .\artifacts --version-suffix=$versionSuffix "
89
+ dotnet pack .\src\JsonApiDotNetCore - c Release - o .\artifacts -- version- suffix= $versionSuffix
101
90
}
102
91
103
92
CheckLastExitCode
0 commit comments