33 [string []][Alias (' p' )]$package ,
44 [string ][Alias (' c' )]$csv ,
55 [string ][Alias (' d' )]$destination ,
6- [ValidateSet (' ref' , ' text' )][string ][Alias (' t' )]$type ,
6+ [ValidateSet (' ref' , ' text' )][string ][Alias (' t' )]$type = ' ref ' ,
77 [switch ][Alias (' x' )]$excludeDependencies ,
8+ [switch ][Alias (' a' )]$regenerateAll ,
89 [string ][Alias (' f' )]$feeds ,
910 [switch ][Alias (' h' )]$help ,
1011 [Parameter (ValueFromRemainingArguments = $true )][String []]$properties
@@ -33,10 +34,41 @@ function Get-Help() {
3334 Write-Host " -d|-destination A path to the root of the repo to copy source into."
3435 Write-Host " -t|-type Type of the package to generate. Accepted values: ref (default) | text."
3536 Write-Host " -x|-excludeDependencies Determines if package dependencies should be excluded. Default is false."
37+ Write-Host " -a|-regenerateAll Regenerate all packages of the specified type."
3638 Write-Host " -f|-feeds A semicolon-separated list of additional NuGet feeds to use during restore."
3739 Write-Host " -h|-help Print help and exit."
3840}
3941
42+ function Initialize-PackageRegeneration {
43+ Write-Host " Discovering packages for regeneration..."
44+
45+ $script :tempCsv = [System.IO.Path ]::GetTempFileName()
46+ $packages = @ ()
47+
48+ if ($type -eq " ref" ) {
49+ $packagesDir = Join-Path $PSScriptRoot " ..\src\referencePackages\src"
50+ } elseif ($type -eq " text" ) {
51+ $packagesDir = Join-Path $PSScriptRoot " ..\src\textOnlyPackages\src"
52+ }
53+
54+ if (Test-Path $packagesDir ) {
55+ $packages = Get-ChildItem $packagesDir - Directory | ForEach-Object {
56+ $pkg = $_.Name
57+ Get-ChildItem $_.FullName - Directory | ForEach-Object { " $pkg ,$ ( $_.Name ) " }
58+ }
59+ }
60+
61+ [System.IO.File ]::WriteAllLines($script :tempCsv , $packages )
62+ if ($packages.Count -eq 0 ) {
63+ Write-Error " No packages found to regenerate"
64+ exit -1
65+ }
66+
67+ Write-Host " Found $ ( $packages.Count ) package(s) to regenerate"
68+
69+ $script :arguments += " /p:PackageCSV=`" $script :tempCsv `" /p:ExcludePackageDependencies=true"
70+ }
71+
4072if ($help -or $ ($PSBoundParameters.Count ) -eq 0 ) {
4173 Get-Help
4274 exit 0
@@ -62,10 +94,25 @@ foreach ($argument in $PSBoundParameters.Keys)
6294 " destination" { $arguments += " /p:PackagesSrcDirectory=`" $ ( $PSBoundParameters [$argument ]) `" " }
6395 " type" { $arguments += " /p:PackageType=$ ( $PSBoundParameters [$argument ]) " }
6496 " excludeDependencies" { $arguments += " /p:ExcludePackageDependencies=true" }
97+ " regenerateAll" { } # Handled separately below
6598 " feeds" { $arguments += " /p:RestoreAdditionalProjectSources=`" $ ( $PSBoundParameters [$argument ]) `" " }
6699 default { $arguments += " $ ( $PSBoundParameters [$argument ]) " }
67100 }
68101}
69102
70- Invoke-Expression " & `" $PSScriptRoot \common\build.ps1`" -restore -build -warnaserror 0 /p:GeneratePackageSource=true $arguments "
103+ $tempCsv = $null
104+
105+ try {
106+ if ($regenerateAll ) {
107+ Initialize-PackageRegeneration
108+ }
109+
110+ Invoke-Expression " & `" $PSScriptRoot \common\build.ps1`" -restore -build -warnaserror 0 /p:GeneratePackageSource=true $arguments "
111+ }
112+ finally {
113+ if ($tempCsv ) {
114+ Remove-Item $tempCsv - ErrorAction SilentlyContinue
115+ }
116+ }
117+
71118exit 0
0 commit comments