Skip to content

Commit 6a29739

Browse files
committed
Merge pull request #77 from PowerShell/daviwil/publish-nuget
Prepare projects and automation for NuGet publishing
2 parents 4397b4a + 69825f8 commit 6a29739

File tree

12 files changed

+158
-21
lines changed

12 files changed

+158
-21
lines changed

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ App_Data
1111
TestResults
1212
[Tt]humbs.db
1313
buildd.*
14-
build/cxtcache/
14+
release/
1515
*.log
1616
*.bak
1717
packages

appveyor.yml

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
version: 0.2.0.{build}
1+
version: '$(core_version).{build}'
22
os: Unstable
33
configuration: Release
44
clone_depth: 10
55

6+
environment:
7+
core_version: '0.2.0'
8+
prerelease_name: '-beta'
9+
610
branches:
711
only:
812
- master
@@ -18,9 +22,9 @@ branches:
1822
assembly_info:
1923
patch: true
2024
file: '**\AssemblyInfo.*'
21-
assembly_version: '0.2.0' # This version number should always have 0 for the last section
25+
assembly_version: '{version}'
2226
assembly_file_version: '{version}'
23-
assembly_informational_version: '{version}'
27+
assembly_informational_version: '$(core_version)$(prerelease_name)+{build}'
2428

2529
install:
2630
- git submodule -q update --init

scripts/FetchLatestBuild.ps1

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
param($buildVersion = $null)
2+
3+
$releasePath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\release")
4+
$binariesToSignPath = [System.IO.Path]::GetFullPath("$releasePath\BinariesToSign")
5+
$unpackedPackagesPath = [System.IO.Path]::GetFullPath("$releasePath\UnpackedPackages")
6+
7+
# Ensure that the release path exists and clear out old folders
8+
mkdir $releasePath -Force | Out-Null
9+
10+
# Install prerequisite packages
11+
#Install-Package -Name "Nito.AsyncEx" -RequiredVersion "3.0.1" -Source "nuget.org" -ProviderName "NuGet" -Destination $buildPath -Force
12+
#Install-Package -Name "Newtonsoft.Json" -RequiredVersion "7.0.1" -Source "nuget.org" -ProviderName "NuGet" -Destination $buildPath -Force
13+
14+
if ($buildVersion -eq $null) {
15+
# Get the current build status
16+
$headers = @{ "Content-Type" = "application/json" }
17+
$project = Invoke-RestMethod -Method Get -Uri "https://ci.appveyor.com/api/projects/PowerShell/PowerShellEditorServices/branch/master" -Headers $headers
18+
$buildVersion = $project.build.version
19+
if ($project.build.status -eq "success") {
20+
Write-Output "Latest build version on master is $buildVersion`r`n"
21+
}
22+
else {
23+
Write-Error "PowerShellEditorServices build $buildVersion was not successful!" -ErrorAction "Stop"
24+
}
25+
}
26+
27+
function Install-BuildPackage($packageName, $extension) {
28+
$uri = "https://ci.appveyor.com/nuget/powershelleditorservices/api/v2/package/{0}/{1}" -f $packageName.ToLower(), $buildVersion
29+
Write-Verbose "Fetching from URI: $uri"
30+
31+
# Download the package and extract it
32+
$zipPath = "$releasePath\$packageName.zip"
33+
$packageContentPath = "$unpackedPackagesPath\$packageName"
34+
Invoke-WebRequest $uri -OutFile $zipPath -ErrorAction "Stop"
35+
Expand-Archive $zipPath -DestinationPath $packageContentPath -Force -ErrorAction "Stop"
36+
Remove-Item $zipPath -ErrorAction "Stop"
37+
38+
# Copy the binary to the binary signing folder
39+
mkdir $binariesToSignPath -Force | Out-Null
40+
cp "$packageContentPath\lib\net45\$packageName.$extension" -Force -Destination $binariesToSignPath
41+
42+
Write-Output "Extracted package $packageName ($buildVersion)"
43+
}
44+
45+
# Pull the build packages from AppVeyor
46+
Install-BuildPackage "Microsoft.PowerShell.EditorServices" "dll"
47+
Install-BuildPackage "Microsoft.PowerShell.EditorServices.Protocol" "dll"
48+
Install-BuildPackage "Microsoft.PowerShell.EditorServices.Host" "exe"
49+
50+
# Open the BinariesToSign folder
51+
& start $binariesToSignPath

scripts/PackageSignedBinaries.ps1

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This script assumes the FetchBuildBinaries.ps1 has been run and
2+
# the binaries in 'release\BinariesToSign' have been signed and
3+
# replaced.
4+
5+
param($FailIfNotSigned = $true)
6+
7+
$releasePath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\release")
8+
$finalPackagePath = [System.IO.Path]::GetFullPath("$releasePath\FinalPackages")
9+
$binariesToSignPath = [System.IO.Path]::GetFullPath("$releasePath\BinariesToSign")
10+
$unpackedPackagesPath = [System.IO.Path]::GetFullPath("$releasePath\UnpackedPackages")
11+
$nugetPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\.nuget\NuGet.exe")
12+
13+
mkdir $finalPackagePath -Force | Out-Null
14+
15+
$binaries = Get-ChildItem $binariesToSignPath
16+
foreach ($binaryPath in $binaries) {
17+
$signature = Get-AuthenticodeSignature $binaryPath.FullName
18+
19+
# TODO: More validation here?
20+
if ($signature.Status -eq "NotSigned" -and $FailIfNotSigned) {
21+
Write-Error "Binary file is not authenticode signed: $binaryPath" -ErrorAction Stop
22+
}
23+
24+
# Copy the file back where it belongs
25+
$packageName = [System.IO.Path]::GetFileNameWithoutExtension($binaryPath)
26+
$packagePath = "$unpackedPackagesPath\$packageName"
27+
cp $binaryPath.FullName -Destination "$packagePath\lib\net45\" -Force
28+
29+
# Repackage the nupkg with NuGet
30+
Push-Location $finalPackagePath
31+
& $nugetPath pack "$packagePath\$packageName.nuspec"
32+
Pop-Location
33+
}

scripts/PublishPackages.ps1

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
$releasePath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\release")
3+
$finalPackagePath = [System.IO.Path]::GetFullPath("$releasePath\FinalPackages")
4+
$nugetPath = [System.IO.Path]::GetFullPath("$PSScriptRoot\..\.nuget\NuGet.exe")
5+
6+
$packages = Get-ChildItem $finalPackagePath -Filter "*.nupkg"
7+
8+
foreach ($package in $packages) {
9+
& $nugetPath push -NonInteractive $package.FullName
10+
if ($LASTEXITCODE -ne 0)
11+
{
12+
Write-Output "`r`n'nuget push' has failed. You may need to run the following command to set the NuGet account API key:`r`n"
13+
Write-Output "& $nuGetPath setApiKey"
14+
break
15+
}
16+
else
17+
{
18+
Write-Output "Pushed package $package.FullName"
19+
}
20+
}
21+
22+
# TODO: Use Find-Package to verify that the package is there?

scripts/ReleaseProcess.md

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
## PowerShell Editor Services Release Process
2+
3+
1. Find the latest build version for the `master` branch on AppVeyor:
4+
5+
2. Run `.\scripts\FetchLatestBuild.ps1`
6+
7+
3. Once this script completes, sign the binaries in `.\release\BinariesToSign`.
8+
9+
4. Once you have the authenticode-signed binaries, copy them back into
10+
`.\release\BinariesToSign`
11+
12+
5. Run `.\scripts\PackageSignedBinaries.ps1`. If any binaries didn't get signed
13+
correctly, this script will tell you. Once this script completes, the updated
14+
.nupkg files will be in `.\release\FinalPackages`
15+
16+
6. Run `.\scripts\PublishPackages.ps1` to publish the final packages to NuGet.

src/PowerShellEditorServices.Host/PowerShellEditorServices.Host.nuspec

+11-5
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,20 @@
33
<metadata>
44
<id>$id$</id>
55
<version>$version$</version>
6-
<title>Windows PowerShell Editor Services - Host Process</title>
6+
<title>PowerShell Editor Services Host Process</title>
77
<authors>$author$</authors>
88
<owners>$author$</owners>
99
<licenseUrl>https://raw.githubusercontent.com/PowerShell/PowerShellEditorServices/master/LICENSE</licenseUrl>
10-
<projectUrl>http://github.com/PowerShell/PowerShellEditorServices</projectUrl>
10+
<projectUrl>https://github.com/PowerShell/PowerShellEditorServices</projectUrl>
1111
<requireLicenseAcceptance>true</requireLicenseAcceptance>
1212
<description>$description$</description>
13-
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
14-
<tags>Microsoft Windows PowerShell editor</tags>
15-
</metadata>
13+
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
14+
<tags>PowerShell editor development language debugging</tags>
15+
<dependencies>
16+
<group>
17+
<dependency id="Microsoft.PowerShell.EditorServices" version="$version$" />
18+
<dependency id="Microsoft.PowerShell.EditorServices.Protocol" version="$version$" />
19+
</group>
20+
</dependencies>
21+
</metadata>
1622
</package>

src/PowerShellEditorServices.Host/Properties/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// General Information about an assembly is controlled through the following
1111
// set of attributes. Change these attribute values to modify the information
1212
// associated with an assembly.
13-
[assembly: AssemblyTitle("PowerShell Editor Services - Host Process")]
13+
[assembly: AssemblyTitle("PowerShell Editor Services Host Process")]
1414
[assembly: AssemblyDescription("Provides a process for hosting the PowerShell Editor Services library exposed by a JSON message protocol.")]
1515
[assembly: AssemblyConfiguration("")]
1616
[assembly: AssemblyCompany("Microsoft")]

src/PowerShellEditorServices.Protocol/PowerShellEditorServices.Protocol.nuspec

+9-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,19 @@
33
<metadata>
44
<id>$id$</id>
55
<version>$version$</version>
6-
<title>Windows PowerShell Editor Services - Standard I/O Transport</title>
6+
<title>PowerShell Editor Services Host Protocol Library</title>
77
<authors>$author$</authors>
88
<owners>$author$</owners>
99
<licenseUrl>https://raw.githubusercontent.com/PowerShell/PowerShellEditorServices/master/LICENSE</licenseUrl>
10-
<projectUrl>http://github.com/PowerShell/PowerShellEditorServices</projectUrl>
10+
<projectUrl>https://github.com/PowerShell/PowerShellEditorServices</projectUrl>
1111
<requireLicenseAcceptance>true</requireLicenseAcceptance>
1212
<description>$description$</description>
13-
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
14-
<tags>Microsoft Windows PowerShell editor</tags>
13+
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
14+
<tags>PowerShell editor development language debugging</tags>
15+
<dependencies>
16+
<group>
17+
<dependency id="Microsoft.PowerShell.EditorServices" version="$version$" />
18+
</group>
19+
</dependencies>
1520
</metadata>
1621
</package>

src/PowerShellEditorServices.Protocol/Properties/AssemblyInfo.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
// General Information about an assembly is controlled through the following
1111
// set of attributes. Change these attribute values to modify the information
1212
// associated with an assembly.
13-
[assembly: AssemblyTitle("PowerShell Editor Services - Standard I/O Transport")]
14-
[assembly: AssemblyDescription("Provides standard I/O transport for the PowerShell Editor Services host process.")]
13+
[assembly: AssemblyTitle("PowerShell Editor Services Host Protocol Library")]
14+
[assembly: AssemblyDescription("Provides message types and client/server APIs for the PowerShell Editor Services JSON protocol.")]
1515
[assembly: AssemblyConfiguration("")]
1616
[assembly: AssemblyCompany("Microsoft")]
1717
[assembly: AssemblyProduct("PowerShell Editor Services")]

src/PowerShellEditorServices/PowerShellEditorServices.nuspec

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
<metadata>
44
<id>$id$</id>
55
<version>$version$</version>
6-
<title>Windows PowerShell Editor Services Library</title>
6+
<title>PowerShell Editor Services</title>
77
<authors>$author$</authors>
88
<owners>$author$</owners>
99
<licenseUrl>https://raw.githubusercontent.com/PowerShell/PowerShellEditorServices/master/LICENSE</licenseUrl>
10-
<projectUrl>http://github.com/PowerShell/PowerShellEditorServices</projectUrl>
10+
<projectUrl>https://github.com/PowerShell/PowerShellEditorServices</projectUrl>
1111
<requireLicenseAcceptance>true</requireLicenseAcceptance>
1212
<description>$description$</description>
13-
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
14-
<tags>Microsoft Windows PowerShell editor</tags>
13+
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
14+
<tags>PowerShell editor development language debugging</tags>
1515
</metadata>
1616
</package>

src/PowerShellEditorServices/Properties/AssemblyInfo.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
// General Information about an assembly is controlled through the following
1111
// set of attributes. Change these attribute values to modify the information
1212
// associated with an assembly.
13-
[assembly: AssemblyTitle("PowerShell Editor Services Library")]
13+
[assembly: AssemblyTitle("PowerShell Editor Services")]
1414
[assembly: AssemblyDescription("Provides common PowerShell editor capabilities as a .NET library.")]
1515
[assembly: AssemblyConfiguration("")]
1616
[assembly: AssemblyCompany("Microsoft")]

0 commit comments

Comments
 (0)