Skip to content

Commit 6dcf9dd

Browse files
committed
Merge pull request #24 from sharwell/prepare-build
Prepare build scripts for preview release
2 parents 2540b39 + 920c64c commit 6dcf9dd

File tree

13 files changed

+217
-30
lines changed

13 files changed

+217
-30
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
packages/
33
bin/
44
obj/
5+
.nuget/NuGet.exe
6+
build/nuget/
57

68
# Per-user files created by Visual Studio
79
.vs/

OpenStackNetAnalyzers.sln

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
2121
README.md = README.md
2222
EndProjectSection
2323
EndProject
24+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "build", "build", "{AC1B917B-2A3D-4BF7-BC83-58A5004052C1}"
25+
ProjectSection(SolutionItems) = preProject
26+
build\build.ps1 = build\build.ps1
27+
build\check-key.ps1 = build\check-key.ps1
28+
build\keys.ps1 = build\keys.ps1
29+
build\push.ps1 = build\push.ps1
30+
build\version.ps1 = build\version.ps1
31+
EndProjectSection
32+
EndProject
2433
Global
2534
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2635
Debug|Any CPU = Debug|Any CPU

OpenStackNetAnalyzers/OpenStackNetAnalyzers.Vsix/OpenStackNetAnalyzers.Vsix.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@
2424
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
2525
<VSSDKTargetPlatformRegRootSuffix>Roslyn</VSSDKTargetPlatformRegRootSuffix>
2626
</PropertyGroup>
27+
<PropertyGroup Condition="'$(BuildingInsideVisualStudio)' != 'true'">
28+
<!-- This property disables extension deployment for command line builds; required for AppVeyor and the build script -->
29+
<DeployExtension>False</DeployExtension>
30+
</PropertyGroup>
2731
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
2832
<DebugSymbols>true</DebugSymbols>
2933
<DebugType>full</DebugType>

OpenStackNetAnalyzers/OpenStackNetAnalyzers/Diagnostic.nuspec

Lines changed: 0 additions & 25 deletions
This file was deleted.

OpenStackNetAnalyzers/OpenStackNetAnalyzers/OpenStackNetAnalyzers.csproj

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,13 @@
3131
<ErrorReport>prompt</ErrorReport>
3232
<WarningLevel>4</WarningLevel>
3333
</PropertyGroup>
34+
<PropertyGroup>
35+
<SignAssembly>true</SignAssembly>
36+
</PropertyGroup>
37+
<PropertyGroup>
38+
<AssemblyOriginatorKeyFile Condition="'$(KeyConfiguration)' == 'Final'">..\..\build\keys\OpenStackNetAnalyzers.snk</AssemblyOriginatorKeyFile>
39+
<AssemblyOriginatorKeyFile Condition="'$(KeyConfiguration)' != 'Final'">..\..\build\keys\OpenStackNetAnalyzers.dev.snk</AssemblyOriginatorKeyFile>
40+
</PropertyGroup>
3441
<ItemGroup>
3542
<Compile Include="AssertNullAnalyzer.cs" />
3643
<Compile Include="CancellationTokenAnalyzer.cs" />
@@ -58,7 +65,13 @@
5865
<Compile Include="XmlSyntaxFactory.cs" />
5966
</ItemGroup>
6067
<ItemGroup>
61-
<None Include="Diagnostic.nuspec">
68+
<None Include="..\..\build\keys\OpenStackNetAnalyzers.dev.snk">
69+
<Link>OpenStackNetAnalyzers.dev.snk</Link>
70+
</None>
71+
<None Include="..\..\build\keys\OpenStackNetAnalyzers.snk">
72+
<Link>OpenStackNetAnalyzers.snk</Link>
73+
</None>
74+
<None Include="OpenStackNetAnalyzers.nuspec">
6275
<SubType>Designer</SubType>
6376
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
6477
</None>
@@ -118,10 +131,6 @@
118131
</Reference>
119132
</ItemGroup>
120133
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\v4.5\Microsoft.Portable.CSharp.targets" />
121-
<PropertyGroup>
122-
<PostBuildEvent>"$(SolutionDir)\packages\NuGet.CommandLine.2.8.2\tools\NuGet.exe" pack Diagnostic.nuspec -NoPackageAnalysis -OutputDirectory .</PostBuildEvent>
123-
<RunPostBuildEvent>OnOutputUpdated</RunPostBuildEvent>
124-
</PropertyGroup>
125134
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
126135
Other similar extension points exist, see Microsoft.Common.targets.
127136
<Target Name="BeforeBuild">
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?xml version="1.0"?>
2+
<package>
3+
<metadata>
4+
<id>OpenStackNetAnalyzers</id>
5+
<version>0.0.0.0</version>
6+
<title>OpenStack.NET Analyzers</title>
7+
<authors>Sam Harwell</authors>
8+
<owners>Sam Harwell</owners>
9+
<licenseUrl>https://raw.githubusercontent.com/openstacknetsdk/OpenStackNetAnalyzers/${version}/LICENSE</licenseUrl>
10+
<projectUrl>https://github.com/openstacknetsdk/OpenStackNetAnalyzers</projectUrl>
11+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
12+
<description>>Roslyn-based analysis and coding assistance for the OpenStack.NET SDK.</description>
13+
<releaseNotes>https://github.com/openstacknetsdk/OpenStackNetAnalyzers/releases/${version}</releaseNotes>
14+
<copyright>Rackspace</copyright>
15+
<tags>openstack roslyn diagnostic analyzers</tags>
16+
</metadata>
17+
<files>
18+
19+
<!--
20+
Note: this package specification is copied to the output folder, and the build script uses it from there. Relative
21+
paths in 'include' and 'exclude' attributes should be relative to the output folder.
22+
-->
23+
24+
<!-- Binaries and symbols -->
25+
<file src="*.dll" target="tools\analyzers\" exclude="**\Microsoft.CodeAnalysis.*;**\System.Collections.Immutable.*;**\System.Reflection.Metadata.*" />
26+
<file src="*.pdb" target="tools\analyzers\" exclude="**\Microsoft.CodeAnalysis.*;**\System.Collections.Immutable.*;**\System.Reflection.Metadata.*" />
27+
28+
<!-- Scripts -->
29+
<file src="tools\*.ps1" target="tools\" />
30+
31+
<!-- Source code -->
32+
<file exclude="..\..\obj\**\*.cs" src="..\..\**\*.cs" target="src"/>
33+
34+
</files>
35+
</package>

build/build.ps1

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
param (
2+
[switch]$Debug,
3+
[string]$VisualStudioVersion = '14.0',
4+
[switch]$SkipKeyCheck,
5+
[string]$Verbosity = 'normal',
6+
[string]$Logger
7+
)
8+
9+
# build the solution
10+
$SolutionPath = "..\OpenStackNetAnalyzers.sln"
11+
12+
# make sure the script was run from the expected path
13+
if (!(Test-Path $SolutionPath)) {
14+
$host.ui.WriteErrorLine('The script was run from an invalid working directory.')
15+
exit 1
16+
}
17+
18+
. .\version.ps1
19+
20+
If ($Debug) {
21+
$BuildConfig = 'Debug'
22+
} Else {
23+
$BuildConfig = 'Release'
24+
}
25+
26+
If ($Version.Contains('-')) {
27+
$KeyConfiguration = 'Dev'
28+
} Else {
29+
$KeyConfiguration = 'Final'
30+
}
31+
32+
# download NuGet.exe if necessary
33+
$nuget = '..\.nuget\NuGet.exe'
34+
If (-not (Test-Path $nuget)) {
35+
If (-not (Test-Path '..\.nuget')) {
36+
mkdir '..\.nuget'
37+
}
38+
39+
$nugetSource = 'http://nuget.org/nuget.exe'
40+
Invoke-WebRequest $nugetSource -OutFile $nuget
41+
If (-not $?) {
42+
$host.ui.WriteErrorLine('Unable to download NuGet executable, aborting!')
43+
exit $LASTEXITCODE
44+
}
45+
}
46+
47+
# build the main project
48+
$msbuild = "${env:ProgramFiles(x86)}\MSBuild\$VisualStudioVersion\Bin\MSBuild.exe"
49+
50+
# Attempt to restore packages up to 3 times, to improve resiliency to connection timeouts and access denied errors.
51+
$maxAttempts = 3
52+
For ($attempt = 0; $attempt -lt $maxAttempts; $attempt++) {
53+
&$nuget 'restore' $SolutionPath
54+
If ($?) {
55+
Break
56+
} ElseIf (($attempt + 1) -eq $maxAttempts) {
57+
$host.ui.WriteErrorLine('Failed to restore required NuGet packages, aborting!')
58+
exit $LASTEXITCODE
59+
}
60+
}
61+
62+
If ($Logger) {
63+
$LoggerArgument = "/logger:$Logger"
64+
}
65+
66+
&$msbuild '/nologo' '/m' '/nr:false' '/t:rebuild' $LoggerArgument "/verbosity:$Verbosity" "/p:Configuration=$BuildConfig" "/p:VisualStudioVersion=$VisualStudioVersion" "/p:KeyConfiguration=$KeyConfiguration" $SolutionPath
67+
If (-not $?) {
68+
$host.ui.WriteErrorLine('Build failed, aborting!')
69+
exit $LASTEXITCODE
70+
}
71+
72+
# By default, do not create a NuGet package unless the expected strong name key files were used
73+
if (-not $SkipKeyCheck) {
74+
. .\keys.ps1
75+
76+
foreach ($pair in $Keys.GetEnumerator()) {
77+
$assembly = Resolve-FullPath -Path "..\OpenStackNetAnalyzers\OpenStackNetAnalyzers\bin\$BuildConfig\OpenStackNetAnalyzers.dll"
78+
# Run the actual check in a separate process or the current process will keep the assembly file locked
79+
powershell -Command ".\check-key.ps1 -Assembly '$assembly' -ExpectedKey '$($pair.Value)' -Build '$($pair.Key)'"
80+
If (-not $?) {
81+
$host.ui.WriteErrorLine('Failed to verify strong name key for build, aborting!')
82+
exit $LASTEXITCODE
83+
}
84+
}
85+
}
86+
87+
if (-not (Test-Path 'nuget')) {
88+
mkdir "nuget"
89+
}
90+
91+
&$nuget 'pack' "..\OpenStackNetAnalyzers\OpenStackNetAnalyzers\bin\$BuildConfig\OpenStackNetAnalyzers.nuspec" '-OutputDirectory' 'nuget' '-Prop' "Configuration=$BuildConfig" '-Version' "$Version" '-Symbols'

build/check-key.ps1

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
param(
2+
[string]$Assembly,
3+
[string]$ExpectedKey,
4+
[string]$Build = $null
5+
)
6+
7+
function Get-PublicKeyToken() {
8+
param([string]$assembly = $null)
9+
if ($assembly) {
10+
$bytes = $null
11+
$bytes = [System.Reflection.Assembly]::ReflectionOnlyLoadFrom($assembly).GetName().GetPublicKeyToken()
12+
if ($bytes) {
13+
$key = ""
14+
for ($i=0; $i -lt $bytes.Length; $i++) {
15+
$key += "{0:x2}" -f $bytes[$i]
16+
}
17+
18+
$key
19+
}
20+
}
21+
}
22+
23+
if (-not $Build) {
24+
$Build = $Assembly
25+
}
26+
27+
$actual = Get-PublicKeyToken -assembly $Assembly
28+
if ($actual -ne $ExpectedKey) {
29+
$host.ui.WriteErrorLine("Invalid publicKeyToken for '$Build'; expected '$ExpectedKey' but found '$actual'")
30+
exit 1
31+
}

build/keys.ps1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Note: these values may only change during major release
2+
3+
If ($Version.Contains('-')) {
4+
5+
# Use the development keys
6+
$Keys = @{
7+
'portable-net45' = '2c3f425faba47628'
8+
}
9+
10+
} Else {
11+
12+
# Use the final release keys
13+
$Keys = @{
14+
'portable-net45' = '2bddc237b520a058'
15+
}
16+
17+
}
18+
19+
function Resolve-FullPath() {
20+
param([string]$Path)
21+
[System.IO.Path]::GetFullPath((Join-Path (pwd) $Path))
22+
}
596 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)