Skip to content

Commit 6e4ab03

Browse files
authored
Publish NuGet from Azure Pipeline build (#510)
* Use build number from Azure Pipelines * Publish NuGet * Fix build.ps1
1 parent 26580e0 commit 6e4ab03

File tree

3 files changed

+29
-8
lines changed

3 files changed

+29
-8
lines changed

PowerShellWorker.Common.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<BuildNumber Condition="$(APPVEYOR) != ''">$(APPVEYOR_BUILD_NUMBER)</BuildNumber>
4-
<BuildNumber Condition="$(APPVEYOR) == ''">$([System.DateTime]::Now.ToString(`MMdd`))</BuildNumber>
3+
<BuildNumber Condition=" '$(BuildNumber)' == '' ">1</BuildNumber>
54
<Version>3.0.$(BuildNumber)</Version>
65
<PackageTags>PowerShell;AzureFunctions;language;Azure;</PackageTags>
76
<PackageLicenseUrl>https://github.com/Azure/azure-functions-powershell-worker/blob/master/LICENSE</PackageLicenseUrl>

azure-pipelines.yml

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,16 @@ pool:
1212

1313
variables:
1414
Configuration: Release
15+
buildNumber: $[ counter('build', 400) ] # Start higher than our AppVeyor versions. Every build (pr or branch) will increment.
1516

1617
steps:
1718
- pwsh: ./build.ps1 -NoBuild -Bootstrap
1819
displayName: 'Running ./build.ps1 -NoBuild -Bootstrap'
1920

2021
- pwsh: |
2122
$ErrorActionPreference = "Stop"
22-
./build.ps1 -Clean -Configuration Release
23-
displayName: './build.ps1 -Clean -Configuration Release'
23+
./build.ps1 -Clean -Configuration Release -BuildNumber "$(buildNumber)"
24+
displayName: 'Build worker code'
2425

2526
- pwsh: ./build.ps1 -NoBuild -Test
2627
displayName: 'Running UnitTest'
@@ -47,4 +48,22 @@ steps:
4748
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
4849
ArtifactName: 'drop'
4950
publishLocation: 'Container'
50-
displayName: 'Publishing build and test result artifacts'
51+
displayName: 'Publishing build and test result artifacts'
52+
53+
- pwsh: |
54+
$sourcePath = (ls package/**/*/Microsoft.Azure.Functions.PowerShellWorker*.nupkg).FullName
55+
if (-not (test-path $sourcePath))
56+
{
57+
throw 'Unable to find Microsoft.Azure.Functions.PowerShellWorker*.nupkg at ./package'
58+
}
59+
Copy-Item -Path $sourcePath -Destination $(Build.ArtifactStagingDirectory) -ErrorAction Stop -Verbose -Force
60+
displayName: 'Copy package to ArtifactStagingDirectory'
61+
62+
- task: NuGetCommand@2
63+
condition: and(ne(variables['Build.Reason'], 'PullRequest'), in(variables['Build.SourceBranchName'], 'v3.x/ps7', 'v3.x/ps6', 'v2.x'))
64+
inputs:
65+
command: 'push'
66+
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
67+
nuGetFeedType: 'internal'
68+
publishVstsFeed: 'e6a70c92-4128-439f-8012-382fe78d6396/c0493cce-bc63-4e11-9fc9-e7c45291f151'
69+
allowPackageConflicts: true

build.ps1

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ param(
1919
$NoBuild,
2020

2121
[string]
22-
$Configuration = "Debug"
22+
$Configuration = "Debug",
23+
24+
[string]
25+
$BuildNumber = '0'
2326
)
2427

2528
#Requires -Version 6.0
@@ -83,8 +86,8 @@ if(!$NoBuild.IsPresent) {
8386
Get-WebFile -Url 'https://raw.githubusercontent.com/PowerShell/PowerShell/master/src/Modules/Windows/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1' `
8487
-OutFile "$PSScriptRoot/src/Modules/Microsoft.PowerShell.Management/Microsoft.PowerShell.Management.psd1"
8588

86-
dotnet publish -c $Configuration $PSScriptRoot
87-
dotnet pack -c $Configuration "$PSScriptRoot/package"
89+
dotnet publish -c $Configuration "/p:BuildNumber=$BuildNumber" $PSScriptRoot
90+
dotnet pack -c $Configuration "/p:BuildNumber=$BuildNumber" "$PSScriptRoot/package"
8891
}
8992

9093
# Test step

0 commit comments

Comments
 (0)