Skip to content

Commit f8089cb

Browse files
committed
Add build scripts
1 parent 9768ead commit f8089cb

10 files changed

Lines changed: 138 additions & 3 deletions

File tree

.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/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.

src/corelib/corelib.v4.0.csproj

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

src/openstack.net.sln

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpCodeSamples", "Sample
4949
EndProject
5050
Project("{7CF6DF6D-3B04-46F8-A40B-537D21BCA0B4}") = "AdditionalReferenceDocumentation", "Documentation\AdditionalReferenceDocumentation.shfbproj", "{1D084AB3-E5DB-4A72-9DAF-E51D225D5FCF}"
5151
EndProject
52+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{EFFA0DAE-1829-4783-92CF-390CFCE22E43}"
53+
ProjectSection(SolutionItems) = preProject
54+
..\build\build.ps1 = ..\build\build.ps1
55+
..\build\check-key.ps1 = ..\build\check-key.ps1
56+
..\build\KeyReporting.targets = ..\build\KeyReporting.targets
57+
..\build\keys.ps1 = ..\build\keys.ps1
58+
..\build\push.ps1 = ..\build\push.ps1
59+
..\build\version.ps1 = ..\build\version.ps1
60+
EndProjectSection
61+
EndProject
5262
Global
5363
GlobalSection(TestCaseManagementSettings) = postSolution
5464
CategoryFile = openstack.net.vsmdi

0 commit comments

Comments
 (0)