Skip to content

Commit e6fde40

Browse files
authored
Merge pull request #56 from libgit2/package-improvements
Package improvements
2 parents 66370b3 + d503444 commit e6fde40

File tree

9 files changed

+116
-90
lines changed

9 files changed

+116
-90
lines changed

UpdateLibgit2ToSha.ps1

Lines changed: 57 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $self = Split-Path -Leaf $MyInvocation.MyCommand.Path
1616
$projectDirectory = Split-Path $MyInvocation.MyCommand.Path
1717
$libgit2Directory = Join-Path $projectDirectory "libgit2"
1818

19-
function Run-Command([scriptblock]$Command, [switch]$Fatal, [switch]$Quiet) {
19+
function Invoke-Command([scriptblock]$Command, [switch]$Fatal, [switch]$Quiet) {
2020
$output = ""
2121
if ($Quiet) {
2222
$output = & $Command 2>&1
@@ -67,18 +67,18 @@ Push-Location $libgit2Directory
6767
$git = Find-Git
6868

6969
Write-Output "Fetching..."
70-
Run-Command -Quiet { & $git fetch }
70+
Invoke-Command -Quiet { & $git fetch }
7171

7272
Write-Output "Verifying $sha..."
7373
$sha = & $git rev-parse $sha
7474
if ($LASTEXITCODE -ne 0) {
7575
write-host -foregroundcolor red "Error: invalid SHA. USAGE: $self <SHA>"
76-
popd
76+
Pop-Location
7777
break
7878
}
7979

8080
Write-Output "Checking out $sha..."
81-
Run-Command -Quiet -Fatal { & $git checkout $sha }
81+
Invoke-Command -Quiet -Fatal { & $git checkout $sha }
8282

8383
Pop-Location
8484

@@ -88,46 +88,63 @@ Push-Location $libgit2Directory
8888
$binaryFilename = "git2-" + $sha.Substring(0,7)
8989
}
9090

91-
sc -Encoding ASCII (Join-Path $projectDirectory "nuget.package\contentFiles\any\any\libgit2_hash.txt") $sha
92-
sc -Encoding ASCII (Join-Path $projectDirectory "nuget.package\contentFiles\any\any\libgit2_filename.txt") $binaryFilename
91+
Set-Content -Encoding ASCII (Join-Path $projectDirectory "nuget.package\libgit2\libgit2_hash.txt") $sha
9392

9493
$buildProperties = @"
95-
<?xml version="1.0" encoding="utf-8"?>
96-
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
97-
<ItemGroup>
98-
<None Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\$binaryFilename.dll')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\$binaryFilename.dll">
99-
<Link>lib\win32\x64\$binaryFilename.dll</Link>
100-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
101-
</None>
102-
<None Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\$binaryFilename.pdb')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\$binaryFilename.pdb">
103-
<Link>lib\win32\x64\$binaryFilename.pdb</Link>
104-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
105-
</None>
106-
<None Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\$binaryFilename.dll')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\$binaryFilename.dll">
107-
<Link>lib\win32\x86\$binaryFilename.dll</Link>
108-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
109-
</None>
110-
<None Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\$binaryFilename.pdb')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\$binaryFilename.pdb">
111-
<Link>lib\win32\x86\$binaryFilename.pdb</Link>
112-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
113-
</None>
114-
<None Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\osx\native\lib$binaryFilename.dylib')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\osx\native\lib$binaryFilename.dylib">
115-
<Link>lib\osx\lib$binaryFilename.dylib</Link>
116-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
117-
</None>
118-
<None Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\linux-x64\native\lib$binaryFilename.so')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\linux-x64\native\lib$binaryFilename.so">
119-
<Link>lib\linux\x86_64\lib$binaryFilename.so</Link>
120-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
121-
</None>
122-
<None Include="`$(MSBuildThisFileDirectory)\..\..\libgit2\LibGit2Sharp.dll.config">
123-
<Link>LibGit2Sharp.dll.config</Link>
124-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
125-
</None>
126-
</ItemGroup>
94+
<Project>
95+
<PropertyGroup>
96+
<MSBuildAllProjects>`$(MSBuildAllProjects);`$(MSBuildThisFileFullPath)</MSBuildAllProjects>
97+
<libgit2_propsfile>`$(MSBuildThisFileFullPath)</libgit2_propsfile>
98+
<libgit2_hash>$sha</libgit2_hash>
99+
<libgit2_filename>$binaryFilename</libgit2_filename>
100+
</PropertyGroup>
101+
</Project>
102+
"@
103+
104+
Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\LibGit2Sharp.NativeBinaries.props") $buildProperties
105+
106+
$net461BuildProperties = @"
107+
<Project>
108+
<PropertyGroup>
109+
<MSBuildAllProjects>`$(MSBuildAllProjects);`$(MSBuildThisFileFullPath)</MSBuildAllProjects>
110+
<libgit2_propsfile>`$(MSBuildThisFileFullPath)</libgit2_propsfile>
111+
<libgit2_hash>$sha</libgit2_hash>
112+
<libgit2_filename>$binaryFilename</libgit2_filename>
113+
</PropertyGroup>
114+
<ItemGroup>
115+
<ContentWithTargetPath Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\$binaryFilename.dll')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\$binaryFilename.dll">
116+
<TargetPath>lib\win32\x64\$binaryFilename.dll</TargetPath>
117+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
118+
</ContentWithTargetPath>
119+
<ContentWithTargetPath Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\$binaryFilename.pdb')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\$binaryFilename.pdb">
120+
<TargetPath>lib\win32\x64\$binaryFilename.pdb</TargetPath>
121+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
122+
</ContentWithTargetPath>
123+
<ContentWithTargetPath Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\$binaryFilename.dll')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\$binaryFilename.dll">
124+
<TargetPath>lib\win32\x86\$binaryFilename.dll</TargetPath>
125+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
126+
</ContentWithTargetPath>
127+
<ContentWithTargetPath Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\$binaryFilename.pdb')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\$binaryFilename.pdb">
128+
<TargetPath>lib\win32\x86\$binaryFilename.pdb</TargetPath>
129+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
130+
</ContentWithTargetPath>
131+
<ContentWithTargetPath Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\osx\native\lib$binaryFilename.dylib')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\osx\native\lib$binaryFilename.dylib">
132+
<TargetPath>lib\osx\lib$binaryFilename.dylib</TargetPath>
133+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
134+
</ContentWithTargetPath>
135+
<ContentWithTargetPath Condition="Exists('`$(MSBuildThisFileDirectory)\..\..\runtimes\linux-x64\native\lib$binaryFilename.so')" Include="`$(MSBuildThisFileDirectory)\..\..\runtimes\linux-x64\native\lib$binaryFilename.so">
136+
<TargetPath>lib\linux\x86_64\lib$binaryFilename.so</TargetPath>
137+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
138+
</ContentWithTargetPath>
139+
<ContentWithTargetPath Include="`$(MSBuildThisFileDirectory)\..\..\libgit2\LibGit2Sharp.dll.config">
140+
<TargetPath>LibGit2Sharp.dll.config</TargetPath>
141+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
142+
</ContentWithTargetPath>
143+
</ItemGroup>
127144
</Project>
128145
"@
129146

130-
sc -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net40\LibGit2Sharp.NativeBinaries.props") $buildProperties
147+
Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\build\net461\LibGit2Sharp.NativeBinaries.props") $net461BuildProperties
131148

132149
$dllConfig = @"
133150
<configuration>
@@ -136,7 +153,7 @@ Push-Location $libgit2Directory
136153
</configuration>
137154
"@
138155

139-
sc -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\libgit2\LibGit2Sharp.dll.config") $dllConfig
156+
Set-Content -Encoding UTF8 (Join-Path $projectDirectory "nuget.package\libgit2\LibGit2Sharp.dll.config") $dllConfig
140157

141158
Write-Output "Done!"
142159
}

build.libgit2.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $projectDirectory = Split-Path $MyInvocation.MyCommand.Path
2222
$libgit2Directory = Join-Path $projectDirectory "libgit2"
2323
$x86Directory = Join-Path $projectDirectory "nuget.package\runtimes\win7-x86\native"
2424
$x64Directory = Join-Path $projectDirectory "nuget.package\runtimes\win7-x64\native"
25-
$hashFile = Join-Path $projectDirectory "nuget.package\contentFiles\any\any\libgit2_hash.txt"
25+
$hashFile = Join-Path $projectDirectory "nuget.package\libgit2\libgit2_hash.txt"
2626
$sha = Get-Content $hashFile
2727

2828
if (![string]::IsNullOrEmpty($libgit2Name)) {

build.libgit2.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
LIBGIT2SHA=`cat ./nuget.package/contentFiles/any/any/libgit2_hash.txt`
3+
LIBGIT2SHA=`cat ./nuget.package/libgit2/libgit2_hash.txt`
44
SHORTSHA=${LIBGIT2SHA:0:7}
55

66
rm -rf libgit2/build

nuget.package/NativeBinaries.nuspec

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
3-
<metadata>
4-
<id>LibGit2Sharp.NativeBinaries</id>
5-
<version>1.0.155</version>
6-
<authors>LibGit2Sharp contributors</authors>
7-
<owners>nulltoken</owners>
8-
<licenseUrl>https://raw.githubusercontent.com/libgit2/libgit2/master/COPYING</licenseUrl>
9-
<projectUrl>https://github.com/libgit2/libgit2sharp.nativebinaries</projectUrl>
10-
<iconUrl>https://raw.githubusercontent.com/libgit2/libgit2sharp/master/square-logo.png</iconUrl>
11-
<requireLicenseAcceptance>false</requireLicenseAcceptance>
12-
<description>Native binaries for LibGit2Sharp</description>
13-
<contentFiles>
14-
<files include="**/*" buildAction="EmbeddedResource" />
15-
</contentFiles>
16-
</metadata>
3+
<metadata>
4+
<id>LibGit2Sharp.NativeBinaries</id>
5+
<version>1.0.155</version>
6+
<authors>LibGit2Sharp contributors</authors>
7+
<owners>nulltoken</owners>
8+
<licenseUrl>https://raw.githubusercontent.com/libgit2/libgit2/master/COPYING</licenseUrl>
9+
<projectUrl>https://github.com/libgit2/libgit2sharp.nativebinaries</projectUrl>
10+
<iconUrl>https://raw.githubusercontent.com/libgit2/libgit2sharp/master/square-logo.png</iconUrl>
11+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
12+
<description>Native binaries for LibGit2Sharp</description>
13+
</metadata>
1714
</package>
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project>
2+
<PropertyGroup>
3+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
4+
<libgit2_propsfile>$(MSBuildThisFileFullPath)</libgit2_propsfile>
5+
<libgit2_hash>15e119375018fba121cf58e02a9f17fe22df0df8</libgit2_hash>
6+
<libgit2_filename>git2-15e1193</libgit2_filename>
7+
</PropertyGroup>
8+
</Project>

nuget.package/build/net40/LibGit2Sharp.NativeBinaries.props

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<Project>
2+
<PropertyGroup>
3+
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
4+
<libgit2_propsfile>$(MSBuildThisFileFullPath)</libgit2_propsfile>
5+
<libgit2_hash>15e119375018fba121cf58e02a9f17fe22df0df8</libgit2_hash>
6+
<libgit2_filename>git2-15e1193</libgit2_filename>
7+
</PropertyGroup>
8+
<ItemGroup>
9+
<ContentWithTargetPath Condition="Exists('$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\git2-15e1193.dll')" Include="$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\git2-15e1193.dll">
10+
<TargetPath>lib\win32\x64\git2-15e1193.dll</TargetPath>
11+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
12+
</ContentWithTargetPath>
13+
<ContentWithTargetPath Condition="Exists('$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\git2-15e1193.pdb')" Include="$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x64\native\git2-15e1193.pdb">
14+
<TargetPath>lib\win32\x64\git2-15e1193.pdb</TargetPath>
15+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
16+
</ContentWithTargetPath>
17+
<ContentWithTargetPath Condition="Exists('$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\git2-15e1193.dll')" Include="$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\git2-15e1193.dll">
18+
<TargetPath>lib\win32\x86\git2-15e1193.dll</TargetPath>
19+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
20+
</ContentWithTargetPath>
21+
<ContentWithTargetPath Condition="Exists('$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\git2-15e1193.pdb')" Include="$(MSBuildThisFileDirectory)\..\..\runtimes\win7-x86\native\git2-15e1193.pdb">
22+
<TargetPath>lib\win32\x86\git2-15e1193.pdb</TargetPath>
23+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
24+
</ContentWithTargetPath>
25+
<ContentWithTargetPath Condition="Exists('$(MSBuildThisFileDirectory)\..\..\runtimes\osx\native\libgit2-15e1193.dylib')" Include="$(MSBuildThisFileDirectory)\..\..\runtimes\osx\native\libgit2-15e1193.dylib">
26+
<TargetPath>lib\osx\libgit2-15e1193.dylib</TargetPath>
27+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
28+
</ContentWithTargetPath>
29+
<ContentWithTargetPath Condition="Exists('$(MSBuildThisFileDirectory)\..\..\runtimes\linux-x64\native\libgit2-15e1193.so')" Include="$(MSBuildThisFileDirectory)\..\..\runtimes\linux-x64\native\libgit2-15e1193.so">
30+
<TargetPath>lib\linux\x86_64\libgit2-15e1193.so</TargetPath>
31+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
32+
</ContentWithTargetPath>
33+
<ContentWithTargetPath Include="$(MSBuildThisFileDirectory)\..\..\libgit2\LibGit2Sharp.dll.config">
34+
<TargetPath>LibGit2Sharp.dll.config</TargetPath>
35+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
36+
</ContentWithTargetPath>
37+
</ItemGroup>
38+
</Project>

nuget.package/contentFiles/any/any/libgit2_filename.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)