diff --git a/azure-pipelines.yml b/azure-pipelines.yml index ab1dc8d..fe4fb2b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -8,6 +8,7 @@ variables: CONFIGURATION: 'Release' BUILD_PRERELEASE: true DOTNET_CORE_VERSION: 8.x + PR_NUMBER: $[coalesce(variables['System.PullRequest.PullRequestNumber'], '0')] jobs: - job: pack @@ -26,7 +27,7 @@ jobs: dotnet tool restore displayName: Restore .NET tools - pwsh: | - dotnet cake --target=Pack --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" + dotnet cake --target=Pack --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$(PR_NUMBER)" displayName: Pack - task: PublishBuildArtifacts@1 displayName: Publish NuGet packages @@ -50,7 +51,7 @@ jobs: dotnet tool restore displayName: Restore .NET tools - pwsh: | - dotnet cake --target=Build --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" + dotnet cake --target=Build --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$(PR_NUMBER)" displayName: Build - job: test @@ -69,7 +70,7 @@ jobs: dotnet tool restore displayName: Restore .NET tools - pwsh: | - dotnet cake --target=Test --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$env:SYSTEM_PULLREQUEST_PULLREQUESTNUMBER" + dotnet cake --target=Test --configuration="$(CONFIGURATION)" --packageVersion="$(PACKAGE_VERSION)" --prerelease="$(BUILD_PRERELEASE)" --pullrequest="$(PR_NUMBER)" displayName: Run tests - task: PublishBuildArtifacts@1 displayName: Publish artifacts diff --git a/build.cake b/build.cake index d7eedea..7c834c2 100644 --- a/build.cake +++ b/build.cake @@ -1,7 +1,7 @@ var target = Argument("target", "Default"); var configuration = Argument("configuration", "Release"); -var pullrequest = Argument("pullrequest", ""); -var prerelease = Argument("prerelease", true) || !string.IsNullOrEmpty(pullrequest); +var pullrequest = Argument("pullrequest", 0); +var prerelease = Argument("prerelease", true) || pullrequest > 0; // a bit of logic to create the version number: // - input = 1.2.3.4 @@ -13,7 +13,7 @@ var assemblyVersion = $"{version.Major}.0.0.0"; var fileVersion = $"{version.Major}.{version.Minor}.{version.Build}.0"; var infoVersion = $"{version.Major}.{version.Minor}.{version.Build}.{version.Revision}"; var packageVersion = $"{version.Major}.{version.Minor}.{version.Build}"; -var previewlabel = string.IsNullOrEmpty(pullrequest) ? "preview" : $"pr.{pullrequest}"; +var previewlabel = pullrequest > 0 ? $"pr.{pullrequest}" : "preview"; var previewVersion = $"{packageVersion}-{previewlabel}.{previewNumber}"; var finalBuildNumber = prerelease ? previewVersion : packageVersion;