Skip to content

Commit 1f45009

Browse files
committed
Merge pull request #408 from sharwell/build-scripts
Build scripts
2 parents a30ca88 + f8089cb commit 1f45009

12 files changed

Lines changed: 147 additions & 179 deletions

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,6 @@ _ReSharper*/
4848
*.resharper
4949
[Tt]est[Rr]esult*
5050

51-
#Project files
52-
[Bb]uild/
53-
5451
#Subversion files
5552
.svn/
5653

build/KeyReporting.targets

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright (c) Rackspace, US Inc. All Rights Reserved. Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.
4+
-->
5+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
6+
7+
<Target Name="EnsureAssemblySigningKeyPresent"
8+
Condition="('$(SignAssembly)' == 'true') And ('$(AssemblyOriginatorKeyFile)' != '')"
9+
BeforeTargets="CoreCompile">
10+
11+
<PropertyGroup>
12+
<ErrorText>This project references a strong name key that is missing on this computer. Run 'sn -k {0}' to generate the file.</ErrorText>
13+
</PropertyGroup>
14+
<Error Condition="!Exists($([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(AssemblyOriginatorKeyFile)')))"
15+
Text="$([System.String]::Format('$(ErrorText)', '$([System.IO.Path]::GetFullPath('$([System.IO.Path]::Combine('$(MSBuildProjectDirectory)', '$(AssemblyOriginatorKeyFile)'))'))'))" />
16+
17+
</Target>
18+
</Project>

build/build.ps1

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
param (
2+
[switch]$Debug,
3+
[string]$VisualStudioVersion = "12.0",
4+
[switch]$SkipKeyCheck,
5+
[switch]$NoDocs
6+
)
7+
8+
# build the solution
9+
$SolutionPath = "..\src\openstack.net.sln"
10+
11+
# make sure the script was run from the expected path
12+
if (!(Test-Path $SolutionPath)) {
13+
$host.ui.WriteErrorLine('The script was run from an invalid working directory.')
14+
exit 1
15+
}
16+
17+
. .\version.ps1
18+
19+
If ($Debug) {
20+
$BuildConfig = 'Debug'
21+
} Else {
22+
$BuildConfig = 'Release'
23+
}
24+
25+
If ($NoDocs -and -not $Debug) {
26+
$SolutionBuildConfig = $BuildConfig + 'NoDocs'
27+
} Else {
28+
$SolutionBuildConfig = $BuildConfig
29+
}
30+
31+
# build the main project
32+
$msbuild = "$env:windir\Microsoft.NET\Framework64\v4.0.30319\msbuild.exe"
33+
34+
&$msbuild '/nologo' '/m' '/nr:false' '/t:rebuild' "/p:Configuration=$SolutionBuildConfig" "/p:Platform=Mixed Platforms" "/p:VisualStudioVersion=$VisualStudioVersion" $SolutionPath
35+
if ($LASTEXITCODE -ne 0) {
36+
$host.ui.WriteErrorLine('Build failed, aborting!')
37+
exit $p.ExitCode
38+
}
39+
40+
# By default, do not create a NuGet package unless the expected strong name key files were used
41+
if (-not $SkipKeyCheck) {
42+
. .\keys.ps1
43+
44+
foreach ($pair in $Keys.GetEnumerator()) {
45+
$assembly = Resolve-FullPath -Path "..\src\corelib\bin\$($pair.Key)\$BuildConfig\openstacknet.dll"
46+
# Run the actual check in a separate process or the current process will keep the assembly file locked
47+
powershell -Command ".\check-key.ps1 -Assembly '$assembly' -ExpectedKey '$($pair.Value)' -Build '$($pair.Key)'"
48+
if ($LASTEXITCODE -ne 0) {
49+
Exit $p.ExitCode
50+
}
51+
}
52+
}
53+
54+
if (-not (Test-Path 'nuget')) {
55+
mkdir "nuget"
56+
}
57+
58+
..\src\.nuget\NuGet.exe 'pack' '..\src\corelib\corelib.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: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Note: these values may only change during minor release
2+
$Keys = @{
3+
'v3.5' = '8965cea5c205d3a3'
4+
'v4.0' = '8965cea5c205d3a3'
5+
}
6+
7+
function Resolve-FullPath() {
8+
param([string]$Path)
9+
[System.IO.Path]::GetFullPath((Join-Path (pwd) $Path))
10+
}

build/push.ps1

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
. .\version.ps1
2+
3+
If ($Version.EndsWith('-dev')) {
4+
$host.ui.WriteErrorLine("Cannot push development version '$Version' to NuGet.")
5+
Exit 1
6+
}
7+
8+
..\src\.nuget\NuGet.exe 'push' ".\nuget\openstack.net.$Version.nupkg"

build/version.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$Version = "1.3.3.0-dev"

src/Documentation/Documentation.v3.5.shfbproj

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<SyntaxFilters>Standard</SyntaxFilters>
3333
<SdkLinkTarget>Blank</SdkLinkTarget>
3434
<RootNamespaceContainer>True</RootNamespaceContainer>
35-
<PresentationStyle>VS2013Alt</PresentationStyle>
35+
<PresentationStyle>VS2013</PresentationStyle>
3636
<Preliminary>False</Preliminary>
3737
<NamingMethod>MemberName</NamingMethod>
3838
<HelpTitle>openstack.net API Reference Documentation</HelpTitle>
@@ -92,9 +92,6 @@
9292
<HelpAttributes />
9393
<NamespaceSummaries />
9494
<PlugInConfigurations>
95-
<PlugInConfig id="Lightweight TOC" enabled="True">
96-
<configuration />
97-
</PlugInConfig>
9895
<PlugInConfig id="Additional Reference Links" enabled="True">
9996
<configuration>
10097
<targets>
@@ -130,13 +127,6 @@
130127
</PropertyGroup>
131128
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
132129
</PropertyGroup>
133-
<ItemGroup>
134-
<ProjectReference Include="..\corelib\corelib.v3.5.csproj">
135-
<Name>corelib.v3.5</Name>
136-
<Project>{e49d9dc3-79d5-4c5e-8c38-fd5060b4e318}</Project>
137-
<Private>True</Private>
138-
</ProjectReference>
139-
</ItemGroup>
140130
<ItemGroup>
141131
<None Include="Content\AsynchronousServices.aml" />
142132
<None Include="Content\Authentication\Authentication.aml" />

src/Documentation/Documentation.v4.0.shfbproj

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
<SyntaxFilters>Standard</SyntaxFilters>
3333
<SdkLinkTarget>Blank</SdkLinkTarget>
3434
<RootNamespaceContainer>True</RootNamespaceContainer>
35-
<PresentationStyle>VS2013Alt</PresentationStyle>
35+
<PresentationStyle>VS2013</PresentationStyle>
3636
<Preliminary>False</Preliminary>
3737
<NamingMethod>MemberName</NamingMethod>
3838
<HelpTitle>openstack.net API Reference Documentation</HelpTitle>
@@ -97,9 +97,6 @@
9797
</versions>
9898
</configuration>
9999
</PlugInConfig>
100-
<PlugInConfig id="Lightweight TOC" enabled="True">
101-
<configuration />
102-
</PlugInConfig>
103100
<PlugInConfig id="Additional Reference Links" enabled="True">
104101
<configuration>
105102
<targets>
@@ -138,13 +135,6 @@
138135
</PropertyGroup>
139136
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|Win32' ">
140137
</PropertyGroup>
141-
<ItemGroup>
142-
<ProjectReference Include="..\corelib\corelib.v4.0.csproj">
143-
<Name>corelib.v4.0</Name>
144-
<Project>{7dba11eb-dba7-4d3a-8d42-b5312e74b9c0}</Project>
145-
<Private>True</Private>
146-
</ProjectReference>
147-
</ItemGroup>
148138
<ItemGroup>
149139
<None Include="Content\AsynchronousServices.aml" />
150140
<None Include="Content\Authentication\Authentication.aml" />

src/corelib/corelib.v3.5.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@
649649
<None Include="Icons\openstack_net_logo.png" />
650650
</ItemGroup>
651651
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
652+
<Import Project="$(SolutionDir)\..\build\KeyReporting.targets" />
652653
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
653654
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
654655
Other similar extension points exist, see Microsoft.Common.targets.

0 commit comments

Comments
 (0)