@@ -29,7 +29,7 @@ $x86Directory = Join-Path $projectDirectory "nuget.package\runtimes\win-x86\nati
2929$x64Directory = Join-Path $projectDirectory " nuget.package\runtimes\win-x64\native"
3030$arm64Directory = Join-Path $projectDirectory " nuget.package\runtimes\win-arm64\native"
3131$hashFile = Join-Path $projectDirectory " nuget.package\libgit2\libgit2_hash.txt"
32- $sha = Get-Content $hashFile
32+ $sha = Get-Content $hashFile
3333$binaryFilename = " git2-" + $sha.Substring (0 , 7 )
3434
3535$build_tests = ' OFF'
@@ -108,9 +108,22 @@ function Install-Libssh2($triplet) {
108108 }
109109 Write-Output " Installing libssh2 for $triplet via vcpkg..."
110110 Run- Command - Fatal { & $vcpkg install " libssh2:$triplet " }
111- }
112111
113- $vcpkgToolchain = Join-Path $Env: VCPKG_INSTALLATION_ROOT " scripts\buildsystems\vcpkg.cmake"
112+ $installedDir = Join-Path $Env: VCPKG_INSTALLATION_ROOT " installed\$triplet "
113+ $libssh2Dll = Join-Path $installedDir " bin\libssh2.dll"
114+ $libssh2Lib = Join-Path $installedDir " lib\libssh2.lib"
115+ $libssh2Include = Join-Path $installedDir " include"
116+
117+ if (-not (Test-Path $libssh2Dll )) {
118+ throw " Error: libssh2.dll not found at $libssh2Dll "
119+ }
120+
121+ return @ {
122+ Dll = $libssh2Dll
123+ Library = $libssh2Lib
124+ IncludeDir = $libssh2Include
125+ }
126+ }
114127
115128try {
116129 if ((! $x86.isPresent -and ! $x64.IsPresent ) -and ! $arm64.IsPresent ) {
@@ -128,9 +141,10 @@ try {
128141 cd build
129142
130143 if ($x86.IsPresent ) {
131- Install-Libssh2 " x86-windows-static"
144+ $ssh2 = Install-Libssh2 " x86-windows"
145+ $vcpkgToolchain = Join-Path $Env: VCPKG_INSTALLATION_ROOT " scripts\buildsystems\vcpkg.cmake"
132146 Write-Output " Building x86..."
133- Run- Command - Fatal { & $cmake - A Win32 - D USE_SSH= ON - D USE_HTTPS= Schannel - D " BUILD_TESTS=$build_tests " - D " BUILD_CLI=OFF" - D " LIBGIT2_FILENAME=$binaryFilename " - D " CMAKE_TOOLCHAIN_FILE=$vcpkgToolchain " - D " VCPKG_TARGET_TRIPLET=x86-windows-static " .. }
147+ Run- Command - Fatal { & $cmake - A Win32 - D USE_SSH= ON - D USE_HTTPS= Schannel - D " BUILD_TESTS=$build_tests " - D " BUILD_CLI=OFF" - D " LIBGIT2_FILENAME=$binaryFilename " - D " CMAKE_TOOLCHAIN_FILE=$vcpkgToolchain " - D " VCPKG_TARGET_TRIPLET=x86-windows" .. }
134148 Run- Command - Fatal { & $cmake -- build . -- config $configuration }
135149 if ($test.IsPresent ) { Run- Command - Quiet - Fatal { & $ctest - V . } }
136150 cd $configuration
@@ -139,15 +153,18 @@ try {
139153 Run- Command - Quiet { & rm $x86Directory \* - ErrorAction Ignore }
140154 Run- Command - Quiet { & mkdir - fo $x86Directory }
141155 Run- Command - Quiet - Fatal { & copy - fo * $x86Directory - Exclude * .lib }
156+ Run- Command - Quiet - Fatal { & copy - fo $ ($ssh2.Dll ) $x86Directory }
157+ Write-Output " Bundled libssh2.dll alongside libgit2"
142158 cd ..
143159 }
144160
145161 if ($x64.IsPresent ) {
146- Install-Libssh2 " x64-windows-static"
162+ $ssh2 = Install-Libssh2 " x64-windows"
163+ $vcpkgToolchain = Join-Path $Env: VCPKG_INSTALLATION_ROOT " scripts\buildsystems\vcpkg.cmake"
147164 Write-Output " Building x64..."
148165 Run- Command - Quiet { & mkdir build64 }
149166 cd build64
150- Run- Command - Fatal { & $cmake - A x64 - D USE_SSH= ON - D USE_HTTPS= Schannel - D " BUILD_TESTS=$build_tests " - D " BUILD_CLI=OFF" - D " LIBGIT2_FILENAME=$binaryFilename " - D " CMAKE_TOOLCHAIN_FILE=$vcpkgToolchain " - D " VCPKG_TARGET_TRIPLET=x64-windows-static " ../ .. }
167+ Run- Command - Fatal { & $cmake - A x64 - D USE_SSH= ON - D USE_HTTPS= Schannel - D " BUILD_TESTS=$build_tests " - D " BUILD_CLI=OFF" - D " LIBGIT2_FILENAME=$binaryFilename " - D " CMAKE_TOOLCHAIN_FILE=$vcpkgToolchain " - D " VCPKG_TARGET_TRIPLET=x64-windows" ../ .. }
151168 Run- Command - Fatal { & $cmake -- build . -- config $configuration }
152169 if ($test.IsPresent ) { Run- Command - Quiet - Fatal { & $ctest - V . } }
153170 cd $configuration
@@ -156,14 +173,17 @@ try {
156173 Run- Command - Quiet { & rm $x64Directory \* - ErrorAction Ignore }
157174 Run- Command - Quiet { & mkdir - fo $x64Directory }
158175 Run- Command - Quiet - Fatal { & copy - fo * $x64Directory - Exclude * .lib }
176+ Run- Command - Quiet - Fatal { & copy - fo $ ($ssh2.Dll ) $x64Directory }
177+ Write-Output " Bundled libssh2.dll alongside libgit2"
159178 }
160179
161180 if ($arm64.IsPresent ) {
162- Install-Libssh2 " arm64-windows-static"
181+ $ssh2 = Install-Libssh2 " arm64-windows"
182+ $vcpkgToolchain = Join-Path $Env: VCPKG_INSTALLATION_ROOT " scripts\buildsystems\vcpkg.cmake"
163183 Write-Output " Building arm64..."
164184 Run- Command - Quiet { & mkdir buildarm64 }
165185 cd buildarm64
166- Run- Command - Fatal { & $cmake - A ARM64 - D USE_SSH= ON - D USE_HTTPS= Schannel - D " BUILD_TESTS=$build_tests " - D " BUILD_CLI=OFF" - D " LIBGIT2_FILENAME=$binaryFilename " - D " CMAKE_TOOLCHAIN_FILE=$vcpkgToolchain " - D " VCPKG_TARGET_TRIPLET=arm64-windows-static " ../ .. }
186+ Run- Command - Fatal { & $cmake - A ARM64 - D USE_SSH= ON - D USE_HTTPS= Schannel - D " BUILD_TESTS=$build_tests " - D " BUILD_CLI=OFF" - D " LIBGIT2_FILENAME=$binaryFilename " - D " CMAKE_TOOLCHAIN_FILE=$vcpkgToolchain " - D " VCPKG_TARGET_TRIPLET=arm64-windows" ../ .. }
167187 Run- Command - Fatal { & $cmake -- build . -- config $configuration }
168188 if ($test.IsPresent ) { Run- Command - Quiet - Fatal { & $ctest - V . } }
169189 cd $configuration
@@ -172,6 +192,8 @@ try {
172192 Run- Command - Quiet { & rm $arm64Directory \* - ErrorAction Ignore }
173193 Run- Command - Quiet { & mkdir - fo $arm64Directory }
174194 Run- Command - Quiet - Fatal { & copy - fo * $arm64Directory - Exclude * .lib }
195+ Run- Command - Quiet - Fatal { & copy - fo $ ($ssh2.Dll ) $arm64Directory }
196+ Write-Output " Bundled libssh2.dll alongside libgit2"
175197 }
176198
177199 Write-Output " Done!"
0 commit comments