Skip to content

Commit 3cd5396

Browse files
authored
Publish NuGet from Azure Pipeline (#511)
* Publish NuGet from Azure Pipeline build (#510) * Use build number from Azure Pipelines * Publish NuGet * Fix build.ps1 * Update azure-pipelines.yml for Azure Pipelines
1 parent 013c04e commit 3cd5396

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-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>2.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: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ 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
- task: PowerShell@2
@@ -41,8 +42,8 @@ steps:
4142

4243
- pwsh: |
4344
$ErrorActionPreference = "Stop"
44-
./build.ps1 -Clean -Configuration Release
45-
displayName: './build.ps1 -Clean -Configuration Release'
45+
./build.ps1 -Clean -Configuration Release -BuildNumber "$(buildNumber)"
46+
displayName: 'Build worker code'
4647

4748
- pwsh: ./build.ps1 -NoBuild -Test
4849
displayName: 'Running UnitTest'
@@ -68,4 +69,23 @@ steps:
6869
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
6970
ArtifactName: 'drop'
7071
publishLocation: 'Container'
71-
displayName: 'Publishing build and test result artifacts'
72+
displayName: 'Publishing build and test result artifacts'
73+
74+
- pwsh: |
75+
$sourcePath = (ls package/**/*/Microsoft.Azure.Functions.PowerShellWorker*.nupkg).FullName
76+
if (-not (test-path $sourcePath))
77+
{
78+
throw 'Unable to find Microsoft.Azure.Functions.PowerShellWorker*.nupkg at ./package'
79+
}
80+
Copy-Item -Path $sourcePath -Destination $(Build.ArtifactStagingDirectory) -ErrorAction Stop -Verbose -Force
81+
displayName: 'Copy package to ArtifactStagingDirectory'
82+
83+
- task: NuGetCommand@2
84+
condition: and(ne(variables['Build.Reason'], 'PullRequest'), in(variables['Build.SourceBranch'], 'refs/heads/v3.x/ps7', 'refs/heads/v3.x/ps6', 'refs/heads/v2.x'))
85+
inputs:
86+
command: 'push'
87+
packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg'
88+
nuGetFeedType: 'internal'
89+
publishVstsFeed: 'e6a70c92-4128-439f-8012-382fe78d6396/c0493cce-bc63-4e11-9fc9-e7c45291f151'
90+
allowPackageConflicts: true
91+
displayName: 'Push NuGet package'

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)