Skip to content

Instantly share code, notes, and snippets.

@Aaronontheweb
Created September 25, 2023 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Aaronontheweb/5f0fdea73af43bd00f698724bf1736c6 to your computer and use it in GitHub Desktop.
Save Aaronontheweb/5f0fdea73af43bd00f698724bf1736c6 to your computer and use it in GitHub Desktop.
Pack all nuget packages in directory
# Get the current directory
$currentDirectory = Get-Location
# Define a common output directory for the packed projects
$outputDirectory = Join-Path -Path $currentDirectory -ChildPath 'packed'
# Create the output directory if it doesn't exist
if (-not (Test-Path $outputDirectory)) {
New-Item -Path $outputDirectory -ItemType Directory
}
# Get a list of all .csproj files and their directory paths
$projectFiles = Get-ChildItem -Path $currentDirectory -Recurse -Filter *.csproj | Select-Object -ExpandProperty DirectoryName | Sort-Object -Unique
# Iterate through each directory and run `dotnet pack -c Release`
foreach ($projectDirectory in $projectFiles) {
Set-Location -Path $projectDirectory
Write-Host "Packing project in $projectDirectory"
dotnet pack -c Release --output $outputDirectory
Set-Location -Path $currentDirectory
}
Write-Host "Completed packing all projects!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment