From 9e087d81b679353491dbd14ff9ba8cb60dffb8e4 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 18 Nov 2017 18:12:39 -0500 Subject: [PATCH 1/6] Use ContentWithTargetPath to hide items from Solution Explorer --- UpdateLibgit2ToSha.ps1 | 63 +++++++++---------- .../net40/LibGit2Sharp.NativeBinaries.props | 63 +++++++++---------- 2 files changed, 62 insertions(+), 64 deletions(-) diff --git a/UpdateLibgit2ToSha.ps1 b/UpdateLibgit2ToSha.ps1 index c073d592..64145414 100644 --- a/UpdateLibgit2ToSha.ps1 +++ b/UpdateLibgit2ToSha.ps1 @@ -92,38 +92,37 @@ Push-Location $libgit2Directory sc -Encoding ASCII (Join-Path $projectDirectory "nuget.package\contentFiles\any\any\libgit2_filename.txt") $binaryFilename $buildProperties = @" - - - - - lib\win32\x64\$binaryFilename.dll - PreserveNewest - - - lib\win32\x64\$binaryFilename.pdb - PreserveNewest - - - lib\win32\x86\$binaryFilename.dll - PreserveNewest - - - lib\win32\x86\$binaryFilename.pdb - PreserveNewest - - - lib\osx\lib$binaryFilename.dylib - PreserveNewest - - - lib\linux\x86_64\lib$binaryFilename.so - PreserveNewest - - - LibGit2Sharp.dll.config - PreserveNewest - - + + + + lib\win32\x64\$binaryFilename.dll + PreserveNewest + + + lib\win32\x64\$binaryFilename.pdb + PreserveNewest + + + lib\win32\x86\$binaryFilename.dll + PreserveNewest + + + lib\win32\x86\$binaryFilename.pdb + PreserveNewest + + + lib\osx\lib$binaryFilename.dylib + PreserveNewest + + + lib\linux\x86_64\lib$binaryFilename.so + PreserveNewest + + + LibGit2Sharp.dll.config + PreserveNewest + + "@ diff --git a/nuget.package/build/net40/LibGit2Sharp.NativeBinaries.props b/nuget.package/build/net40/LibGit2Sharp.NativeBinaries.props index c6d2ddb1..ad0a3af6 100644 --- a/nuget.package/build/net40/LibGit2Sharp.NativeBinaries.props +++ b/nuget.package/build/net40/LibGit2Sharp.NativeBinaries.props @@ -1,33 +1,32 @@ - - - - - lib\win32\x64\git2-15e1193.dll - PreserveNewest - - - lib\win32\x64\git2-15e1193.pdb - PreserveNewest - - - lib\win32\x86\git2-15e1193.dll - PreserveNewest - - - lib\win32\x86\git2-15e1193.pdb - PreserveNewest - - - lib\osx\libgit2-15e1193.dylib - PreserveNewest - - - lib\linux\x86_64\libgit2-15e1193.so - PreserveNewest - - - LibGit2Sharp.dll.config - PreserveNewest - - + + + + lib\win32\x64\git2-15e1193.dll + PreserveNewest + + + lib\win32\x64\git2-15e1193.pdb + PreserveNewest + + + lib\win32\x86\git2-15e1193.dll + PreserveNewest + + + lib\win32\x86\git2-15e1193.pdb + PreserveNewest + + + lib\osx\libgit2-15e1193.dylib + PreserveNewest + + + lib\linux\x86_64\libgit2-15e1193.so + PreserveNewest + + + LibGit2Sharp.dll.config + PreserveNewest + + From b02d5e3ce6bebcb8513d0f37a56abd3ccfa4e1fd Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 18 Nov 2017 18:28:28 -0500 Subject: [PATCH 2/6] Pass libgit2 info via MSBuild properties instead of files --- UpdateLibgit2ToSha.ps1 | 22 ++++++++++++---- nuget.package/NativeBinaries.nuspec | 25 ++++++++----------- .../build/LibGit2Sharp.NativeBinaries.props | 6 +++++ .../net40/LibGit2Sharp.NativeBinaries.props | 4 +++ .../contentFiles/any/any/libgit2_filename.txt | 1 - .../contentFiles/any/any/libgit2_hash.txt | 1 - 6 files changed, 38 insertions(+), 21 deletions(-) create mode 100644 nuget.package/build/LibGit2Sharp.NativeBinaries.props delete mode 100644 nuget.package/contentFiles/any/any/libgit2_filename.txt delete mode 100644 nuget.package/contentFiles/any/any/libgit2_hash.txt diff --git a/UpdateLibgit2ToSha.ps1 b/UpdateLibgit2ToSha.ps1 index 64145414..7ddc7078 100644 --- a/UpdateLibgit2ToSha.ps1 +++ b/UpdateLibgit2ToSha.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS - Updates the libgit2 submodule to the specified commit and updates libgit2_hash.txt and NativeBinaries.props with the new hash value. + Updates the libgit2 submodule to the specified commit and updates NativeBinaries.props with the new hash value. .PARAMETER sha Desired libgit2 version. This is run through `git rev-parse`, so branch names are okay too. #> @@ -88,11 +88,23 @@ Push-Location $libgit2Directory $binaryFilename = "git2-" + $sha.Substring(0,7) } - sc -Encoding ASCII (Join-Path $projectDirectory "nuget.package\contentFiles\any\any\libgit2_hash.txt") $sha - sc -Encoding ASCII (Join-Path $projectDirectory "nuget.package\contentFiles\any\any\libgit2_filename.txt") $binaryFilename - $buildProperties = @" + + $sha + $binaryFilename + + +"@ + + sc -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\LibGit2Sharp.NativeBinaries.props") $buildProperties + + $net40BuildProperties = @" + + + $sha + $binaryFilename + lib\win32\x64\$binaryFilename.dll @@ -126,7 +138,7 @@ Push-Location $libgit2Directory "@ - sc -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net40\LibGit2Sharp.NativeBinaries.props") $buildProperties + sc -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net40\LibGit2Sharp.NativeBinaries.props") $net40BuildProperties $dllConfig = @" diff --git a/nuget.package/NativeBinaries.nuspec b/nuget.package/NativeBinaries.nuspec index ea37928b..360bfb72 100644 --- a/nuget.package/NativeBinaries.nuspec +++ b/nuget.package/NativeBinaries.nuspec @@ -1,17 +1,14 @@  - - LibGit2Sharp.NativeBinaries - 1.0.155 - LibGit2Sharp contributors - nulltoken - https://raw.githubusercontent.com/libgit2/libgit2/master/COPYING - https://github.com/libgit2/libgit2sharp.nativebinaries - https://raw.githubusercontent.com/libgit2/libgit2sharp/master/square-logo.png - false - Native binaries for LibGit2Sharp - - - - + + LibGit2Sharp.NativeBinaries + 1.0.155 + LibGit2Sharp contributors + nulltoken + https://raw.githubusercontent.com/libgit2/libgit2/master/COPYING + https://github.com/libgit2/libgit2sharp.nativebinaries + https://raw.githubusercontent.com/libgit2/libgit2sharp/master/square-logo.png + false + Native binaries for LibGit2Sharp + diff --git a/nuget.package/build/LibGit2Sharp.NativeBinaries.props b/nuget.package/build/LibGit2Sharp.NativeBinaries.props new file mode 100644 index 00000000..03715db5 --- /dev/null +++ b/nuget.package/build/LibGit2Sharp.NativeBinaries.props @@ -0,0 +1,6 @@ + + + 15e119375018fba121cf58e02a9f17fe22df0df8 + git2-15e1193 + + diff --git a/nuget.package/build/net40/LibGit2Sharp.NativeBinaries.props b/nuget.package/build/net40/LibGit2Sharp.NativeBinaries.props index ad0a3af6..105329c1 100644 --- a/nuget.package/build/net40/LibGit2Sharp.NativeBinaries.props +++ b/nuget.package/build/net40/LibGit2Sharp.NativeBinaries.props @@ -1,4 +1,8 @@  + + 15e119375018fba121cf58e02a9f17fe22df0df8 + git2-15e1193 + lib\win32\x64\git2-15e1193.dll diff --git a/nuget.package/contentFiles/any/any/libgit2_filename.txt b/nuget.package/contentFiles/any/any/libgit2_filename.txt deleted file mode 100644 index d5bd7b7e..00000000 --- a/nuget.package/contentFiles/any/any/libgit2_filename.txt +++ /dev/null @@ -1 +0,0 @@ -git2-15e1193 diff --git a/nuget.package/contentFiles/any/any/libgit2_hash.txt b/nuget.package/contentFiles/any/any/libgit2_hash.txt deleted file mode 100644 index 3975f631..00000000 --- a/nuget.package/contentFiles/any/any/libgit2_hash.txt +++ /dev/null @@ -1 +0,0 @@ -15e119375018fba121cf58e02a9f17fe22df0df8 From 122f4ce6510fdbbb43e3984201427cc599aa396a Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 18 Nov 2017 18:36:02 -0500 Subject: [PATCH 3/6] Add libgit2_hash.txt to libgit2 folder It's needed when building libgit2, and it's useful to have in the package. --- UpdateLibgit2ToSha.ps1 | 4 +++- build.libgit2.ps1 | 2 +- build.libgit2.sh | 2 +- nuget.package/libgit2/libgit2_hash.txt | 1 + 4 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 nuget.package/libgit2/libgit2_hash.txt diff --git a/UpdateLibgit2ToSha.ps1 b/UpdateLibgit2ToSha.ps1 index 7ddc7078..8f268a45 100644 --- a/UpdateLibgit2ToSha.ps1 +++ b/UpdateLibgit2ToSha.ps1 @@ -1,6 +1,6 @@ <# .SYNOPSIS - Updates the libgit2 submodule to the specified commit and updates NativeBinaries.props with the new hash value. + Updates the libgit2 submodule to the specified commit and updates libgit2_hash.txt and NativeBinaries.props with the new hash value. .PARAMETER sha Desired libgit2 version. This is run through `git rev-parse`, so branch names are okay too. #> @@ -88,6 +88,8 @@ Push-Location $libgit2Directory $binaryFilename = "git2-" + $sha.Substring(0,7) } + sc -Encoding ASCII (Join-Path $projectDirectory "nuget.package\libgit2\libgit2_hash.txt") $sha + $buildProperties = @" diff --git a/build.libgit2.ps1 b/build.libgit2.ps1 index 9eb1be23..6e683e40 100644 --- a/build.libgit2.ps1 +++ b/build.libgit2.ps1 @@ -22,7 +22,7 @@ $projectDirectory = Split-Path $MyInvocation.MyCommand.Path $libgit2Directory = Join-Path $projectDirectory "libgit2" $x86Directory = Join-Path $projectDirectory "nuget.package\runtimes\win7-x86\native" $x64Directory = Join-Path $projectDirectory "nuget.package\runtimes\win7-x64\native" -$hashFile = Join-Path $projectDirectory "nuget.package\contentFiles\any\any\libgit2_hash.txt" +$hashFile = Join-Path $projectDirectory "nuget.package\libgit2\libgit2_hash.txt" $sha = Get-Content $hashFile if (![string]::IsNullOrEmpty($libgit2Name)) { diff --git a/build.libgit2.sh b/build.libgit2.sh index 0676b098..61a6b269 100755 --- a/build.libgit2.sh +++ b/build.libgit2.sh @@ -1,6 +1,6 @@ #!/bin/bash -LIBGIT2SHA=`cat ./nuget.package/contentFiles/any/any/libgit2_hash.txt` +LIBGIT2SHA=`cat ./nuget.package/libgit2/libgit2_hash.txt` SHORTSHA=${LIBGIT2SHA:0:7} rm -rf libgit2/build diff --git a/nuget.package/libgit2/libgit2_hash.txt b/nuget.package/libgit2/libgit2_hash.txt new file mode 100644 index 00000000..3975f631 --- /dev/null +++ b/nuget.package/libgit2/libgit2_hash.txt @@ -0,0 +1 @@ +15e119375018fba121cf58e02a9f17fe22df0df8 From 9f13bdd45f79d3011ccec86b0a679ad2239987e3 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 18 Nov 2017 18:47:15 -0500 Subject: [PATCH 4/6] Fix warnings about script content --- UpdateLibgit2ToSha.ps1 | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/UpdateLibgit2ToSha.ps1 b/UpdateLibgit2ToSha.ps1 index 8f268a45..5019affc 100644 --- a/UpdateLibgit2ToSha.ps1 +++ b/UpdateLibgit2ToSha.ps1 @@ -16,7 +16,7 @@ $self = Split-Path -Leaf $MyInvocation.MyCommand.Path $projectDirectory = Split-Path $MyInvocation.MyCommand.Path $libgit2Directory = Join-Path $projectDirectory "libgit2" -function Run-Command([scriptblock]$Command, [switch]$Fatal, [switch]$Quiet) { +function Invoke-Command([scriptblock]$Command, [switch]$Fatal, [switch]$Quiet) { $output = "" if ($Quiet) { $output = & $Command 2>&1 @@ -67,18 +67,18 @@ Push-Location $libgit2Directory $git = Find-Git Write-Output "Fetching..." - Run-Command -Quiet { & $git fetch } + Invoke-Command -Quiet { & $git fetch } Write-Output "Verifying $sha..." $sha = & $git rev-parse $sha if ($LASTEXITCODE -ne 0) { write-host -foregroundcolor red "Error: invalid SHA. USAGE: $self " - popd + Pop-Location break } Write-Output "Checking out $sha..." - Run-Command -Quiet -Fatal { & $git checkout $sha } + Invoke-Command -Quiet -Fatal { & $git checkout $sha } Pop-Location @@ -88,7 +88,7 @@ Push-Location $libgit2Directory $binaryFilename = "git2-" + $sha.Substring(0,7) } - sc -Encoding ASCII (Join-Path $projectDirectory "nuget.package\libgit2\libgit2_hash.txt") $sha + Set-Content -Encoding ASCII (Join-Path $projectDirectory "nuget.package\libgit2\libgit2_hash.txt") $sha $buildProperties = @" @@ -99,7 +99,7 @@ Push-Location $libgit2Directory "@ - sc -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\LibGit2Sharp.NativeBinaries.props") $buildProperties + Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\LibGit2Sharp.NativeBinaries.props") $buildProperties $net40BuildProperties = @" @@ -140,7 +140,7 @@ Push-Location $libgit2Directory "@ - sc -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net40\LibGit2Sharp.NativeBinaries.props") $net40BuildProperties + Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net40\LibGit2Sharp.NativeBinaries.props") $net40BuildProperties $dllConfig = @" @@ -149,7 +149,7 @@ Push-Location $libgit2Directory "@ - sc -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\libgit2\LibGit2Sharp.dll.config") $dllConfig + Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\libgit2\LibGit2Sharp.dll.config") $dllConfig Write-Output "Done!" } From 6de8fc097ae540b9e3fadb8d2aa1bcf86c27e1b8 Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 18 Nov 2017 19:08:44 -0500 Subject: [PATCH 5/6] Move framework props file to net461 folder --- UpdateLibgit2ToSha.ps1 | 4 ++-- .../build/{net40 => net461}/LibGit2Sharp.NativeBinaries.props | 0 2 files changed, 2 insertions(+), 2 deletions(-) rename nuget.package/build/{net40 => net461}/LibGit2Sharp.NativeBinaries.props (100%) diff --git a/UpdateLibgit2ToSha.ps1 b/UpdateLibgit2ToSha.ps1 index 5019affc..9b7d9762 100644 --- a/UpdateLibgit2ToSha.ps1 +++ b/UpdateLibgit2ToSha.ps1 @@ -101,7 +101,7 @@ Push-Location $libgit2Directory Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\LibGit2Sharp.NativeBinaries.props") $buildProperties - $net40BuildProperties = @" + $net461BuildProperties = @" $sha @@ -140,7 +140,7 @@ Push-Location $libgit2Directory "@ - Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net40\LibGit2Sharp.NativeBinaries.props") $net40BuildProperties + Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net461\LibGit2Sharp.NativeBinaries.props") $net461BuildProperties $dllConfig = @" diff --git a/nuget.package/build/net40/LibGit2Sharp.NativeBinaries.props b/nuget.package/build/net461/LibGit2Sharp.NativeBinaries.props similarity index 100% rename from nuget.package/build/net40/LibGit2Sharp.NativeBinaries.props rename to nuget.package/build/net461/LibGit2Sharp.NativeBinaries.props From d503444882353d6d5706e4eebf7a8e08af6c8f2f Mon Sep 17 00:00:00 2001 From: Brandon Ording Date: Sat, 18 Nov 2017 20:05:05 -0500 Subject: [PATCH 6/6] Add properties to allow for incremental building --- UpdateLibgit2ToSha.ps1 | 4 ++++ nuget.package/build/LibGit2Sharp.NativeBinaries.props | 2 ++ nuget.package/build/net461/LibGit2Sharp.NativeBinaries.props | 2 ++ 3 files changed, 8 insertions(+) diff --git a/UpdateLibgit2ToSha.ps1 b/UpdateLibgit2ToSha.ps1 index 9b7d9762..72802528 100644 --- a/UpdateLibgit2ToSha.ps1 +++ b/UpdateLibgit2ToSha.ps1 @@ -93,6 +93,8 @@ Push-Location $libgit2Directory $buildProperties = @" + `$(MSBuildAllProjects);`$(MSBuildThisFileFullPath) + `$(MSBuildThisFileFullPath) $sha $binaryFilename @@ -104,6 +106,8 @@ Push-Location $libgit2Directory $net461BuildProperties = @" + `$(MSBuildAllProjects);`$(MSBuildThisFileFullPath) + `$(MSBuildThisFileFullPath) $sha $binaryFilename diff --git a/nuget.package/build/LibGit2Sharp.NativeBinaries.props b/nuget.package/build/LibGit2Sharp.NativeBinaries.props index 03715db5..0f19fc60 100644 --- a/nuget.package/build/LibGit2Sharp.NativeBinaries.props +++ b/nuget.package/build/LibGit2Sharp.NativeBinaries.props @@ -1,5 +1,7 @@  + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + $(MSBuildThisFileFullPath) 15e119375018fba121cf58e02a9f17fe22df0df8 git2-15e1193 diff --git a/nuget.package/build/net461/LibGit2Sharp.NativeBinaries.props b/nuget.package/build/net461/LibGit2Sharp.NativeBinaries.props index 105329c1..184e5b36 100644 --- a/nuget.package/build/net461/LibGit2Sharp.NativeBinaries.props +++ b/nuget.package/build/net461/LibGit2Sharp.NativeBinaries.props @@ -1,5 +1,7 @@  + $(MSBuildAllProjects);$(MSBuildThisFileFullPath) + $(MSBuildThisFileFullPath) 15e119375018fba121cf58e02a9f17fe22df0df8 git2-15e1193