[export] Get vcpkg.exe into the nupkg. (#2134)

Hopefully resolves https://github.com/microsoft/vcpkg/issues/53515
This commit is contained in:
Billy O'Neal authored and GitHub committed 2026-09-24 12:36:25 -07:00
1 parent 24c14b8c8f
commit 8fc19740a2
2 files changed
+62 -5

No files matched your search

@@ -22,13 +22,64 @@ if (-Not $zipFilesExist)
throw "No zip files found in $outputDir"
}
# Check existence of NuGet file(s)
$nuGetFilesExist = Test-Path "$outputDir/*.nupkg"
if (-Not $nuGetFilesExist)
# Check contents of NuGet file(s)
$nuGetFiles = Get-ChildItem "$outputDir/*.nupkg"
if ($nuGetFiles.Count -eq 0)
{
throw "No NuGet files found in $outputDir"
}
foreach ($nuGetFile in $nuGetFiles)
{
$archive = [System.IO.Compression.ZipFile]::OpenRead($nuGetFile)
try
{
$entryNames = $archive.Entries.FullName
$packageId = $nuGetFile.BaseName -replace "\.1\.0\.0$", ""
$expectedFiles = @(
".vcpkg-root",
"build/native/$packageId.props",
"build/native/$packageId.targets"
)
if ($IsWindows)
{
$expectedFiles += "vcpkg.exe"
}
foreach ($expectedFile in $expectedFiles)
{
if ($entryNames -notcontains $expectedFile)
{
throw "$nuGetFile does not contain $expectedFile"
}
}
$redirects = @{
"build/native/$packageId.props" = "../../scripts/buildsystems/msbuild/vcpkg.props"
"build/native/$packageId.targets" = "../../scripts/buildsystems/msbuild/vcpkg.targets"
}
foreach ($redirect in $redirects.GetEnumerator())
{
$reader = [System.IO.StreamReader]::new($archive.GetEntry($redirect.Key).Open())
try
{
if ($reader.ReadToEnd() -notlike "*$($redirect.Value)*")
{
throw "$nuGetFile contains an invalid $($redirect.Key)"
}
}
finally
{
$reader.Dispose()
}
}
}
finally
{
$archive.Dispose()
}
}
# Check existence of 7zip file(s)
$sevenZipFilesExist = Test-Path "$outputDir/*.7z"
if (-Not $sevenZipFilesExist)
@@ -63,5 +114,3 @@ if ($out -notmatch "Refusing to create an export of zero packages. Install packa
{
throw "Expected to fail and print warning about empty export plan."
}
+8
View File
@@ -56,6 +56,14 @@ namespace
.finish_self_closing_complex_tag()
.line_break();
#if defined(_WIN32)
xml.start_complex_open_tag("file")
.text_attr("src", raw_exported_dir.native() + "\\vcpkg.exe")
.text_attr("target", "")
.finish_self_closing_complex_tag()
.line_break();
#endif
xml.start_complex_open_tag("file")
.text_attr("src", targets_redirect_path)
.text_attr("target", Strings::concat("build\\native\\", nuget_id, ".targets"))