-
Notifications
You must be signed in to change notification settings - Fork 3
/
NuGet-publish.ps1
53 lines (43 loc) · 1.46 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
42
43
44
45
46
47
48
49
50
51
52
53
# Run this file with powershell to publish package to NuGet
$nuget_url = "https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
function WriteMessage ([string] $message){
Write-Host $message -ForegroundColor Yellow -BackgroundColor Black
}
function Pause ($message = "Press any key to continue . . . ") {
if ((Test-Path variable:psISE) -and $psISE) {
$Shell = New-Object -ComObject "WScript.Shell"
$Button = $Shell.Popup("Click OK to continue.", 0, "Script Paused", 0)
}
else {
WriteMessage $message
[void][System.Console]::ReadKey($true)
Write-Host
}
}
WriteMessage "Downloading nuget.exe"
Invoke-WebRequest -Uri $nuget_url -OutFile "nuget.exe"
WriteMessage "Remember to update release notes in UriBuilderExtended/UriBuilderExtended.nuspec"
Pause
WriteMessage "Creating package"
./nuget pack UriBuilderExtended\UriBuilderExtended.csproj -Prop Configuration=Release
$file = Get-ChildItem *.nupkg
$package = ""
if($file -is [System.IO.FileSystemInfo])
{
$package = $file.Name
}
if($package -ne "")
{
WriteMessage "Package created: $package"
WriteMessage "Pushing package"
$api_key = Read-Host "Please enter API key"
./nuget push $package -Source nuget.org -ApiKey $api_key -NonInteractive
}
else
{
WriteMessage "Unable to detect package after creation. Please clean the directory for any existing packages."
}
WriteMessage "Cleaning up"
Remove-Item "nuget.exe"
Remove-Item $package