-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathdeploy.ps1
More file actions
66 lines (55 loc) · 1.77 KB
/
Copy pathdeploy.ps1
File metadata and controls
66 lines (55 loc) · 1.77 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<#
.SYNOPSIS
Local powershell script buld and deploy nuget packages.
.DESCRIPTION
Run from the repository root. Uses dotnet pack and nuget.exe to build and
publish nuget packages. Often used to publish experimental beta versions
without going through the formal CICD pipeline.
.PARAMETER apikey
API Key for nuget.org
.EXAMPLE
.\deploy.ps1
#>
[cmdletbinding()]
param([Parameter(Mandatory)][string]$apikey, [switch]$publish = $false)
$rootDir = Get-Location
$srcDir = Get-ChildItem ./src
$outputDir = Join-Path -Path $rootDir -ChildPath '/packOutput'
Write-Output `n
if (-not (Test-Path -Path $outputDir -PathType Container)) {
Write-Output "Creating output directory: $outputDir"
New-Item -Path $outputDir -ItemType Directory
}
Write-Output "Cleaning output directory: $outputDir"
Remove-Item $outputDir\*
Write-Output `n
if(!$config){
$config = "Release"
Write-Output "Configuration $config"
}
Write-Output "restoring packages"
& dotnet restore
[object[]]$projectFolders = $NULL
# loop through projects and collect src and test project paths
foreach ($folder in $srcDir) {
$p = Join-Path -Path $folder.FullName -ChildPath '*.csproj';
# only src project folders -> folders with a csproj file
if (Test-Path $p -PathType Leaf) {
$projectFolders += $folder.FullName
}
}
foreach($srcFolder in $projectFolders){
Write-Output "Build packages"
& dotnet pack $srcFolder -c $config -o $outputDir -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
}
Write-Output `n
if($publish){
Write-Output "Publish packages"
& dotnet nuget push $outputDir\*.* -s https://api.nuget.org/v3/index.json -k $apikey
Write-Output `n
}
else
{
Write-Output "Skiped publishing packages; use the -publish switch to publish"
}
Write-Output "Done"