Skip to content

Commit 906794e

Browse files
committed
applied build diff from @nulltoken
libgit2#1009 (comment)
1 parent 891924a commit 906794e

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

appveyor.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ cache:
5454
before_build:
5555
- nuget restore "%APPVEYOR_BUILD_FOLDER%\LibGit2Sharp.sln"
5656

57-
after_build:
58-
- ps: sourcelink index -u 'https://raw.githubusercontent.com/libgit2/libgit2sharp/{0}/%var2%' -pr LibGit2Sharp\LibGit2Sharp.csproj -pp Configuration Release -nf LibGit2Sharp\Core\UniqueIdentifier.cs -nf LibGit2Sharp\Properties\AssemblyInfo.cs
59-
6057
build_script:
6158
- msbuild "%APPVEYOR_BUILD_FOLDER%\LibGit2Sharp.sln" /verbosity:normal /p:Configuration=Release /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" /property:ExtraDefine="LEAKS_IDENTIFYING"
6259

@@ -66,7 +63,7 @@ test_script:
6663

6764
on_success:
6865
- ps: |
69-
& "$env:APPVEYOR_BUILD_FOLDER\nuget.package\BuildNugetPackage.ps1" "$env:APPVEYOR_REPO_COMMIT"
66+
& "$env:APPVEYOR_BUILD_FOLDER\nuget.package\BuildNugetPackage.ps1" -commitSha "$env:APPVEYOR_REPO_COMMIT" -postBuild { sourcelink index -u 'https://raw.githubusercontent.com/libgit2/libgit2sharp/{0}/%var2%' -pr LibGit2Sharp\LibGit2Sharp.csproj -pp Configuration Release -nf LibGit2Sharp\Core\UniqueIdentifier.cs -nf LibGit2Sharp\Properties\AssemblyInfo.cs }
7067
Add-Type -Path "$env:APPVEYOR_BUILD_FOLDER\LibGit2Sharp\bin\Release\LibGit2Sharp.dll"
7168
Write-Host "LibGit2Sharp version = $([LibGit2Sharp.GlobalSettings]::Version)" -ForegroundColor "Magenta"
7269
#If ($Env:SHOULD_PUBLISH_NUGET_ARTIFACT -eq $True)

nuget.package/BuildNugetPackage.ps1

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
Param(
1010
[Parameter(Mandatory=$true)]
11-
[string]$commitSha
11+
[string]$commitSha,
12+
[scriptblock]$postBuild
1213
)
1314

1415
$ErrorActionPreference = "Stop"
@@ -51,21 +52,40 @@ function Clean-OutputFolder($folder) {
5152
}
5253
}
5354

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+
5463
#################
5564

5665
$root = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
5766
$projectPath = Join-Path $root "..\LibGit2Sharp"
67+
$slnPath = Join-Path $projectPath "..\LibGit2Sharp.sln"
5868

5969
Remove-Item (Join-Path $projectPath "*.nupkg")
6070

71+
Clean-OutputFolder (Join-Path $projectPath "bin\")
72+
Clean-OutputFolder (Join-Path $projectPath "obj\")
73+
6174
# The nuspec file needs to be next to the csproj, so copy it there during the pack operation
6275
Copy-Item (Join-Path $root "LibGit2Sharp.nuspec") $projectPath
6376

6477
Push-Location $projectPath
6578

6679
try {
6780
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+
6989
Run-Command { & "$(Join-Path $projectPath "..\Lib\NuGet\Nuget.exe")" Pack -Prop Configuration=Release }
7090
}
7191
finally {

0 commit comments

Comments
 (0)