Skip to content
This repository was archived by the owner on Apr 27, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,11 @@ stages:
displayName: Build / Test
env:
TRYDOTNET_PACKAGES_PATH: $(TryDotNetPackagesPath)

#---------------------------------------------------------------------------------------------------------------------#
# Package upload #
#---------------------------------------------------------------------------------------------------------------------#
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- template: eng/upload/upload-packages.yml
parameters:
branchToUpload: refs/heads/master
41 changes: 41 additions & 0 deletions eng/upload/scripts/UploadPackages.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[CmdletBinding(PositionalBinding=$false)]
param (
[string]$apiKey,
[string]$feedUrl,
[string]$packagesDir
)

Set-StrictMode -version 2.0
$ErrorActionPreference = "Stop"

try {
$packagePatterns = @(
"Microsoft.dotnet-interactive.*.nupkg",
"Microsoft.DotNet.Interactive.*.nupkg" # note that this also matches Microsoft.DotNet.Interactive.Formatting
)

$errors = 0
foreach ($pattern in $packagePatterns) {
foreach ($packageName in (Get-Item "$packagesDir\$pattern")) {
$fullPath = $packageName.ToString()
Write-Host "Uploading package $fullPath."
$response = Invoke-WebRequest -Uri $feedUrl -Headers @{"X-NuGet-ApiKey"=$apiKey} -ContentType "multipart/form-data" -InFile "$fullPath" -Method Post -UseBasicParsing
if ($response.StatusCode -ne 201) {
Write-Host "Failed to upload package. Status code: $response.StatusCode."
$errors++
}
else {
Write-Host "Done."
}
}
}

exit $errors

}
catch {
Write-Host $_
Write-Host $_.Exception
Write-Host $_.ScriptStackTrace
exit 1
}
27 changes: 27 additions & 0 deletions eng/upload/upload-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
parameters:
branchToUpload: ''

stages:
- stage: upload
dependsOn: build
displayName: Upload packages to MyGet
jobs:
- job: Upload_Packages
pool:
vmImage: windows-2019
variables:
- group: dotnet-try-myget-api-keys
- name: FeedUrl
value: 'https://dotnet.myget.org/F/dotnet-try/api/v2/package'
steps:
- task: DownloadBuildArtifacts@0
displayName: Download package artifacts
inputs:
buildType: current
artifactName: packages
- task: PowerShell@2
displayName: Upload packages to MyGet
inputs:
filePath: $(Build.SourcesDirectory)/eng/upload/scripts/UploadPackages.ps1
arguments: -apiKey $(MyGetAPIKey) -feedUrl $(FeedUrl) -packagesDir $(Build.ArtifactStagingDirectory)\packages\Shipping
condition: and(succeeded(), eq(variables['Build.SourceBranch'], '${{ parameters.branchToUpload }}'))