forked from pglazkov/MvvmValidation
-
Notifications
You must be signed in to change notification settings - Fork 0
/
nuget-publish.ps1
41 lines (35 loc) · 1.35 KB
/
nuget-publish.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
39
40
41
$keyfile = "$env:userprofile\Documents\nuget-api-key.txt"
$scriptpath = split-path -parent $MyInvocation.MyCommand.Path
$nugetpath = resolve-path "$scriptpath/Tools/NuGet.exe"
$packagespath = resolve-path "$scriptpath/Output"
if(-not (test-path $keyfile)) {
throw "Could not find the NuGet access key at $keyfile."
}
else {
pushd $packagespath
# get our secret key. This is not in the repository.
$key = get-content $keyfile
# Find all the packages and display them for confirmation
$packages = dir "*.nupkg"
write-host "Packages to upload:"
$packages | % { write-host $_.Name }
# Ensure we haven't run this by accident.
$yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "Uploads the packages."
$no = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "Does not upload the packages."
$options = [System.Management.Automation.Host.ChoiceDescription[]]($no, $yes)
$result = $host.ui.PromptForChoice("Upload packages", "Do you want to upload the NuGet packages to the NuGet server?", $options, 0)
# Cancelled
if($result -eq 0) {
"Upload aborted"
}
# upload
elseif($result -eq 1) {
$packages | % {
$package = $_.Name
write-host "Uploading $package"
& $nugetpath push $package $key
write-host ""
}
}
popd
}