|
8 | 8 |
|
9 | 9 | Param(
|
10 | 10 | [Parameter(Mandatory=$true)]
|
11 |
| - [string]$commitSha |
| 11 | + [string]$commitSha, |
| 12 | + [scriptblock]$postBuild |
12 | 13 | )
|
13 | 14 |
|
14 | 15 | $ErrorActionPreference = "Stop"
|
@@ -51,21 +52,40 @@ function Clean-OutputFolder($folder) {
|
51 | 52 | }
|
52 | 53 | }
|
53 | 54 |
|
| 55 | +# From http://www.dougfinke.com/blog/index.php/2010/12/01/note-to-self-how-to-programmatically-get-the-msbuild-path-in-powershell/ |
| 56 | + |
| 57 | +Function Get-MSBuild { |
| 58 | + $lib = [System.Runtime.InteropServices.RuntimeEnvironment] |
| 59 | + $rtd = $lib::GetRuntimeDirectory() |
| 60 | + Join-Path $rtd msbuild.exe |
| 61 | +} |
| 62 | + |
54 | 63 | #################
|
55 | 64 |
|
56 | 65 | $root = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
|
57 | 66 | $projectPath = Join-Path $root "..\LibGit2Sharp"
|
| 67 | +$slnPath = Join-Path $projectPath "..\LibGit2Sharp.sln" |
58 | 68 |
|
59 | 69 | Remove-Item (Join-Path $projectPath "*.nupkg")
|
60 | 70 |
|
| 71 | +Clean-OutputFolder (Join-Path $projectPath "bin\") |
| 72 | +Clean-OutputFolder (Join-Path $projectPath "obj\") |
| 73 | + |
61 | 74 | # The nuspec file needs to be next to the csproj, so copy it there during the pack operation
|
62 | 75 | Copy-Item (Join-Path $root "LibGit2Sharp.nuspec") $projectPath
|
63 | 76 |
|
64 | 77 | Push-Location $projectPath
|
65 | 78 |
|
66 | 79 | try {
|
67 | 80 | Set-Content -Encoding ASCII $(Join-Path $projectPath "libgit2sharp_hash.txt") $commitSha
|
68 |
| - Run-Command { & "$(Join-Path $projectPath "..\Lib\NuGet\Nuget.exe")" Restore "$(Join-Path $projectPath "..\LibGit2Sharp.sln")" } |
| 81 | + Run-Command { & "$(Join-Path $projectPath "..\Lib\NuGet\Nuget.exe")" Restore "$slnPath" } |
| 82 | + Run-Command { & (Get-MSBuild) "$slnPath" "/verbosity:minimal" "/p:Configuration=Release" } |
| 83 | + |
| 84 | + If ($postBuild) { |
| 85 | + Write-Host -ForegroundColor "Green" "Run post build script..." |
| 86 | + Run-Command { & ($postBuild) } |
| 87 | + } |
| 88 | + |
69 | 89 | Run-Command { & "$(Join-Path $projectPath "..\Lib\NuGet\Nuget.exe")" Pack -Prop Configuration=Release }
|
70 | 90 | }
|
71 | 91 | finally {
|
|
0 commit comments