Save/Save-NuGetPackage.ps1
<#
.SYNOPSIS Function to save and push application packages to a NuGet feed. .DESCRIPTION The `Save-NuGetPackage` function scans a specified directory for application files (.app), packages them into NuGet packages, and pushes them to a specified NuGet feed. .PARAMETER nugetFeed Specifies the URL of the NuGet feed where the packages will be pushed. For example, `https://pkgs.dev.azure.com/smart365/5697519e-e648-48c1-a3b4-0f623d3f2fa3/_packaging/Ukrainian-language/nuget/v3/index.json`. .PARAMETER appBasePath Specifies the path to the directory containing the application files (.app) to be packaged and pushed. For example, `$(Pipeline.Workspace)\output`. .EXAMPLE $nugetFeed = "https://pkgs.dev.azure.com/smart365/5697519e-e648-48c1-a3b4-0f623d3f2fa3/_packaging/Ukrainian-language/nuget/v3/index.json" $appBasePath = "$(Pipeline.Workspace)\output" Save-NuGetPackage -nugetFeed $nugetFeed -appBasePath $appBasePath .NOTES This function is designed to work with Azure Artifacts and NuGet feeds. #> function Save-NuGetPackage { param ( [string]$nugetFeed, [string]$appBasePath ) $appFiles = Get-ChildItem -Path $appBasePath -Filter *.app $tempFolder = $appBasePath Set-Location -Path $tempFolder foreach ($appFile in $appFiles) { $fileName = [System.IO.Path]::GetFileName($appFile) Write-Host "##[group]Push $fileName on Azure Artifacts" Write-Output "Push $appFile on Azure Artifacts" $nupkgFile = New-BcNuGetPackage -appfile $appFile.FullName & nuget.exe push -Source $nugetFeed -ApiKey az $nupkgFile -SkipDuplicate Write-Host "##[endgroup]" } } |