|
7 | 7 | #> |
8 | 8 |
|
9 | 9 | Param( |
10 | | - [Parameter(Mandatory=$true)] |
11 | | - [string]$commitSha, |
12 | 10 | [scriptblock]$postBuild |
13 | 11 | ) |
14 | 12 |
|
@@ -60,34 +58,37 @@ Function Get-MSBuild { |
60 | 58 |
|
61 | 59 | ################# |
62 | 60 |
|
| 61 | +$configuration = 'release' |
63 | 62 | $root = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition |
| 63 | +$OutDir = Join-Path $root "bin\$configuration" |
64 | 64 | $projectPath = Join-Path $root "..\LibGit2Sharp" |
65 | 65 | $slnPath = Join-Path $projectPath "..\LibGit2Sharp.sln" |
| 66 | +$nuspecPath = Join-Path $root 'LibGit2Sharp.nuspec' |
66 | 67 |
|
67 | | -Remove-Item (Join-Path $projectPath "*.nupkg") |
68 | | - |
69 | | -Clean-OutputFolder (Join-Path $projectPath "bin\") |
70 | | -Clean-OutputFolder (Join-Path $projectPath "obj\") |
71 | | - |
72 | | -# The nuspec file needs to be next to the csproj, so copy it there during the pack operation |
73 | | -Copy-Item (Join-Path $root "LibGit2Sharp.nuspec") $projectPath |
| 68 | +if (-not (Test-Path $OutDir)) { |
| 69 | + $null = md $OutDir |
| 70 | +} |
| 71 | +Remove-Item (Join-Path $OutDir "*.nupkg") |
74 | 72 |
|
75 | | -Push-Location $projectPath |
| 73 | +Push-Location $root |
76 | 74 |
|
77 | 75 | try { |
| 76 | + $DependencyBasePath = $null # workaround script issue in NB.GV |
| 77 | + $versionInfo = & "$env:userprofile\.nuget\packages\Nerdbank.GitVersioning\1.5.51\tools\Get-Version.ps1" |
| 78 | + $commitSha = $versionInfo.GitCommitId |
| 79 | + |
78 | 80 | Set-Content -Encoding ASCII $(Join-Path $projectPath "libgit2sharp_hash.txt") $commitSha |
79 | 81 | Run-Command { & "$(Join-Path $projectPath "..\Lib\NuGet\Nuget.exe")" Restore "$slnPath" } |
80 | | - Run-Command { & (Get-MSBuild) "$slnPath" "/verbosity:minimal" "/p:Configuration=Release" "/m" } |
| 82 | + Run-Command { & (Get-MSBuild) "$slnPath" "/verbosity:minimal" "/p:Configuration=$configuration" "/m" } |
81 | 83 |
|
82 | 84 | If ($postBuild) { |
83 | 85 | Write-Host -ForegroundColor "Green" "Run post build script..." |
84 | 86 | Run-Command { & ($postBuild) } |
85 | 87 | } |
86 | 88 |
|
87 | | - Run-Command { & "$(Join-Path $projectPath "..\Lib\NuGet\Nuget.exe")" Pack -Prop Configuration=Release } |
| 89 | + Run-Command { & "$(Join-Path $projectPath "..\Lib\NuGet\Nuget.exe")" Pack $nuspecPath -OutputDirectory $OutDir -Prop "Configuration=$configuration;GitCommitIdShort=$($versionInfo.GitCommitIdShort)" -Version "$($versionInfo.NuGetPackageVersion)" } |
88 | 90 | } |
89 | 91 | finally { |
90 | 92 | Pop-Location |
91 | | - Remove-Item (Join-Path $projectPath "LibGit2Sharp.nuspec") |
92 | 93 | Set-Content -Encoding ASCII $(Join-Path $projectPath "libgit2sharp_hash.txt") "unknown" |
93 | 94 | } |
0 commit comments