This repository has been archived by the owner on Nov 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added build scripts and strong name keys
- Loading branch information
Showing
9 changed files
with
176 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
param ( | ||
[switch]$Debug, | ||
[string]$VisualStudioVersion = '14.0', | ||
[switch]$SkipKeyCheck, | ||
[string]$Verbosity = 'normal', | ||
[string]$Logger | ||
) | ||
|
||
# build the solution | ||
$SolutionPath = "..\AsyncUsageAnalyzers.sln" | ||
|
||
# make sure the script was run from the expected path | ||
if (!(Test-Path $SolutionPath)) { | ||
$host.ui.WriteErrorLine('The script was run from an invalid working directory.') | ||
exit 1 | ||
} | ||
|
||
. .\version.ps1 | ||
|
||
If ($Debug) { | ||
$BuildConfig = 'Debug' | ||
} Else { | ||
$BuildConfig = 'Release' | ||
} | ||
|
||
If ($Version.Contains('-')) { | ||
$KeyConfiguration = 'Dev' | ||
} Else { | ||
$KeyConfiguration = 'Final' | ||
} | ||
|
||
# download NuGet.exe if necessary | ||
$nuget = '..\.nuget\NuGet.exe' | ||
If (-not (Test-Path $nuget)) { | ||
If (-not (Test-Path '..\.nuget')) { | ||
mkdir '..\.nuget' | ||
} | ||
|
||
$nugetSource = 'http://nuget.org/nuget.exe' | ||
Invoke-WebRequest $nugetSource -OutFile $nuget | ||
If (-not $?) { | ||
$host.ui.WriteErrorLine('Unable to download NuGet executable, aborting!') | ||
exit $LASTEXITCODE | ||
} | ||
} | ||
|
||
# build the main project | ||
$msbuild = "${env:ProgramFiles(x86)}\MSBuild\$VisualStudioVersion\Bin\MSBuild.exe" | ||
|
||
# Attempt to restore packages up to 3 times, to improve resiliency to connection timeouts and access denied errors. | ||
$maxAttempts = 3 | ||
For ($attempt = 0; $attempt -lt $maxAttempts; $attempt++) { | ||
&$nuget 'restore' $SolutionPath | ||
If ($?) { | ||
Break | ||
} ElseIf (($attempt + 1) -eq $maxAttempts) { | ||
$host.ui.WriteErrorLine('Failed to restore required NuGet packages, aborting!') | ||
exit $LASTEXITCODE | ||
} | ||
} | ||
|
||
If ($Logger) { | ||
$LoggerArgument = "/logger:$Logger" | ||
} | ||
|
||
&$msbuild '/nologo' '/m' '/nr:false' '/t:rebuild' $LoggerArgument "/verbosity:$Verbosity" "/p:Configuration=$BuildConfig" "/p:VisualStudioVersion=$VisualStudioVersion" "/p:KeyConfiguration=$KeyConfiguration" $SolutionPath | ||
If (-not $?) { | ||
$host.ui.WriteErrorLine('Build failed, aborting!') | ||
exit $LASTEXITCODE | ||
} | ||
|
||
# By default, do not create a NuGet package unless the expected strong name key files were used | ||
if (-not $SkipKeyCheck) { | ||
. .\keys.ps1 | ||
|
||
foreach ($pair in $Keys.GetEnumerator()) { | ||
$assembly = Resolve-FullPath -Path "..\AsyncUsageAnalyzers\AsyncUsageAnalyzers\bin\$BuildConfig\AsyncUsageAnalyzers.dll" | ||
# Run the actual check in a separate process or the current process will keep the assembly file locked | ||
powershell -Command ".\check-key.ps1 -Assembly '$assembly' -ExpectedKey '$($pair.Value)' -Build '$($pair.Key)'" | ||
If (-not $?) { | ||
$host.ui.WriteErrorLine('Failed to verify strong name key for build, aborting!') | ||
exit $LASTEXITCODE | ||
} | ||
} | ||
} | ||
|
||
if (-not (Test-Path 'nuget')) { | ||
mkdir "nuget" | ||
} | ||
|
||
Copy-Item "..\AsyncUsageAnalyzers\AsyncUsageAnalyzers\bin\$BuildConfig\AsyncUsageAnalyzers.$Version.nupkg" 'nuget' | ||
Copy-Item "..\AsyncUsageAnalyzers\AsyncUsageAnalyzers\bin\$BuildConfig\AsyncUsageAnalyzers.$Version.symbols.nupkg" 'nuget' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
param( | ||
[string]$Assembly, | ||
[string]$ExpectedKey, | ||
[string]$Build = $null | ||
) | ||
|
||
function Get-PublicKeyToken() { | ||
param([string]$assembly = $null) | ||
if ($assembly) { | ||
$bytes = $null | ||
$bytes = [System.Reflection.Assembly]::ReflectionOnlyLoadFrom($assembly).GetName().GetPublicKeyToken() | ||
if ($bytes) { | ||
$key = "" | ||
for ($i=0; $i -lt $bytes.Length; $i++) { | ||
$key += "{0:x2}" -f $bytes[$i] | ||
} | ||
|
||
$key | ||
} | ||
} | ||
} | ||
|
||
if (-not $Build) { | ||
$Build = $Assembly | ||
} | ||
|
||
$actual = Get-PublicKeyToken -assembly $Assembly | ||
if ($actual -ne $ExpectedKey) { | ||
$host.ui.WriteErrorLine("Invalid publicKeyToken for '$Build'; expected '$ExpectedKey' but found '$actual'") | ||
exit 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Note: these values may only change during major release | ||
|
||
If ($Version.Contains('-')) { | ||
|
||
# Use the development keys | ||
$Keys = @{ | ||
'portable-net45' = '71b21a4aa82ae3b3' | ||
} | ||
|
||
} Else { | ||
|
||
# Use the final release keys | ||
$Keys = @{ | ||
'portable-net45' = '2d9feb668c6a0e40' | ||
} | ||
|
||
} | ||
|
||
function Resolve-FullPath() { | ||
param([string]$Path) | ||
[System.IO.Path]::GetFullPath((Join-Path (pwd) $Path)) | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
. .\version.ps1 | ||
|
||
If ($Version.EndsWith('-dev')) { | ||
$host.ui.WriteErrorLine("Cannot push development version '$Version' to NuGet.") | ||
Exit 1 | ||
} | ||
|
||
..\.nuget\NuGet.exe 'push' ".\nuget\AsyncUsageAnalyzers.$Version.nupkg" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
$Version = "1.0.0-dev" |