diff --git a/azure-pipelines/end-to-end-tests-dir/commands.export.ps1 b/azure-pipelines/end-to-end-tests-dir/commands.export.ps1 index ead465d0b..a47c41f1f 100644 --- a/azure-pipelines/end-to-end-tests-dir/commands.export.ps1 +++ b/azure-pipelines/end-to-end-tests-dir/commands.export.ps1 @@ -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." } - - diff --git a/src/vcpkg/commands.export.cpp b/src/vcpkg/commands.export.cpp index 314882d5e..a126e77c1 100644 --- a/src/vcpkg/commands.export.cpp +++ b/src/vcpkg/commands.export.cpp @@ -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"))