Created
September 25, 2023 21:50
-
-
Save Aaronontheweb/5f0fdea73af43bd00f698724bf1736c6 to your computer and use it in GitHub Desktop.
Pack all nuget packages in directory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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