-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocal-package.ps1
38 lines (33 loc) · 1.48 KB
/
local-package.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
param(
[Parameter(Mandatory=$true)]
[string]$Mode,
[Parameter(Mandatory=$true)]
[string]$LocalRepoPath,
[Parameter(Mandatory=$false)]
[string]$MajorVersion = "1.100"
)
$ErrorActionPreference = 'Stop'
if ($Mode -eq "add") {
$configPath = "$LocalRepoPath\.rocketcress-config.json"
if (Test-Path $configPath -PathType Leaf) {
$config = Get-Content $configPath -Raw | ConvertFrom-Json
}
else {
$config = @{ lastLocalVersion = 0 }
}
Set-Location $PSScriptRoot
$config.lastLocalVersion++
dotnet pack "-p:Version=$MajorVersion.$($config.lastLocalVersion)" -c Release --force --include-source
ConvertTo-Json $config -Depth 99 | Set-Content $configPath
Get-ChildItem "bin\Release\Serviceware.Rocketcress.*.$MajorVersion.$($config.lastLocalVersion).nupkg" | ForEach-Object { nuget add $_ -source $LocalRepoPath }
Write-Host "Successfully add local packages" -ForegroundColor Green
Write-Host "Run `"dotnet restore --force`" for the project that should use the local package"
}
elseif ($Mode -eq "cleanup") {
Get-ChildItem "$LocalRepoPath\rocketcress*" | ForEach-Object { Remove-Item $_ -Force -Recurse }
Get-ChildItem "$env:USERPROFILE\.nuget\packages\serviceware.rocketcress*\*" | ForEach-Object { Remove-Item $_ -Force -Recurse }
Write-Host "Local Rocketcress packages were removed" -ForegroundColor Green
}
else {
Write-Host "The mode `"$Mode`" is unknwon. You can use `"add`" or `"cleanup`"" -ForegroundColor Red
}