aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorras0219 <robertallenschumacher@gmail.com>2020-06-30 14:02:26 -0700
committerGitHub <noreply@github.com>2020-06-30 14:02:26 -0700
commit3f6342db6ded036422886da6ccf8191685dc2ccf (patch)
treec1377b8116c1ca8b8ef61fdbf6c8fa6b4dcc1dad /toolsrc/src
parent1d8f0acc9c3085d18152a3f639077a28109196b6 (diff)
downloadvcpkg-3f6342db6ded036422886da6ccf8191685dc2ccf.tar.gz
vcpkg-3f6342db6ded036422886da6ccf8191685dc2ccf.zip
[vcpkg] Fix `vcpkg export --nuget` regressions (#12174)
* [vcpkg] Upgrade find_acquire_program(NUGET) to 5.5.1. Add partial SHA to temporary download paths to avoid collisions. * [vcpkg] Fix regression in `vcpkg export --nuget` due to file locking on .vcpkg-root Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg/base/files.cpp23
-rw-r--r--toolsrc/src/vcpkg/export.cpp16
-rw-r--r--toolsrc/src/vcpkg/tools.cpp17
3 files changed, 33 insertions, 23 deletions
diff --git a/toolsrc/src/vcpkg/base/files.cpp b/toolsrc/src/vcpkg/base/files.cpp
index 1ec9a19e4..9d9aecb69 100644
--- a/toolsrc/src/vcpkg/base/files.cpp
+++ b/toolsrc/src/vcpkg/base/files.cpp
@@ -209,6 +209,14 @@ namespace vcpkg::Files
std::error_code ec;
return this->create_directories(path, ec);
}
+ void Filesystem::copy_file(const fs::path& oldpath, const fs::path& newpath, fs::copy_options opts, LineInfo li)
+ {
+ std::error_code ec;
+ this->copy_file(oldpath, newpath, opts, ec);
+ if (ec)
+ vcpkg::Checks::exit_with_message(
+ li, "error copying file from %s to %s: %s", oldpath.u8string(), newpath.u8string(), ec.message());
+ }
fs::file_status Filesystem::status(vcpkg::LineInfo li, const fs::path& p) const noexcept
{
@@ -848,14 +856,13 @@ namespace vcpkg::Files
#if defined(WIN32)
constexpr static auto busy_error = ERROR_BUSY;
const auto system_try_take_file_lock = [&] {
- auto handle = CreateFileW(
- system_file_name.c_str(),
- GENERIC_READ,
- 0 /* no sharing */,
- nullptr /* no security attributes */,
- OPEN_ALWAYS,
- FILE_ATTRIBUTE_NORMAL,
- nullptr /* no template file */);
+ auto handle = CreateFileW(system_file_name.c_str(),
+ GENERIC_READ,
+ 0 /* no sharing */,
+ nullptr /* no security attributes */,
+ OPEN_ALWAYS,
+ FILE_ATTRIBUTE_NORMAL,
+ nullptr /* no template file */);
if (handle == INVALID_HANDLE_VALUE)
{
const auto err = GetLastError();
diff --git a/toolsrc/src/vcpkg/export.cpp b/toolsrc/src/vcpkg/export.cpp
index 138c03b3f..48e9747b3 100644
--- a/toolsrc/src/vcpkg/export.cpp
+++ b/toolsrc/src/vcpkg/export.cpp
@@ -240,7 +240,6 @@ namespace vcpkg::Export
void export_integration_files(const fs::path& raw_exported_dir_path, const VcpkgPaths& paths)
{
const std::vector<fs::path> integration_files_relative_to_root = {
- {".vcpkg-root"},
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "applocal.ps1"},
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "vcpkg.targets"},
{fs::path{"scripts"} / "buildsystems" / "msbuild" / "vcpkg.props"},
@@ -249,17 +248,15 @@ namespace vcpkg::Export
{fs::path{"scripts"} / "cmake" / "vcpkg_get_windows_sdk.cmake"},
};
+ Files::Filesystem& fs = paths.get_filesystem();
for (const fs::path& file : integration_files_relative_to_root)
{
const fs::path source = paths.root / file;
fs::path destination = raw_exported_dir_path / file;
- Files::Filesystem& fs = paths.get_filesystem();
- std::error_code ec;
- fs.create_directories(destination.parent_path(), ec);
- Checks::check_exit(VCPKG_LINE_INFO, !ec);
- fs.copy_file(source, destination, fs::copy_options::overwrite_existing, ec);
- Checks::check_exit(VCPKG_LINE_INFO, !ec);
+ fs.create_directories(destination.parent_path(), ignore_errors);
+ fs.copy_file(source, destination, fs::copy_options::overwrite_existing, VCPKG_LINE_INFO);
}
+ fs.write_contents(raw_exported_dir_path / fs::u8path(".vcpkg-root"), "", VCPKG_LINE_INFO);
}
struct ExportArguments
@@ -591,7 +588,10 @@ With a project open, go to Tools->NuGet Package Manager->Package Manager Console
{
if (paths.manifest_mode_enabled())
{
- Checks::exit_with_message(VCPKG_LINE_INFO, "vcpkg export does not support manifest mode, in order to allow for future design considerations. You may use export in classic mode by running vcpkg outside of a manifest-based project.");
+ Checks::exit_with_message(
+ VCPKG_LINE_INFO,
+ "vcpkg export does not support manifest mode, in order to allow for future design considerations. You "
+ "may use export in classic mode by running vcpkg outside of a manifest-based project.");
}
const StatusParagraphs status_db = database_load_check(paths);
const auto opts = handle_export_command_arguments(args, default_triplet, status_db);
diff --git a/toolsrc/src/vcpkg/tools.cpp b/toolsrc/src/vcpkg/tools.cpp
index 717a7dbcf..687950096 100644
--- a/toolsrc/src/vcpkg/tools.cpp
+++ b/toolsrc/src/vcpkg/tools.cpp
@@ -108,14 +108,17 @@ namespace vcpkg
const std::string tool_dir_name = Strings::format("%s-%s-%s", tool, version_as_string, OS_STRING);
const fs::path tool_dir_path = paths.tools / tool_dir_name;
const fs::path exe_path = tool_dir_path / exe_relative_path;
+ fs::path download_path;
+ if (auto a = archive_name.get())
+ {
+ download_path = paths.downloads / fs::u8path(a->to_string());
+ }
+ else
+ {
+ download_path = paths.downloads / fs::u8path(Strings::concat(sha512.substr(0, 8), '-', exe_relative_path));
+ }
- return ToolData{*version.get(),
- exe_path,
- url,
- paths.downloads / archive_name.value_or(exe_relative_path).to_string(),
- archive_name.has_value(),
- tool_dir_path,
- sha512};
+ return ToolData{*version.get(), exe_path, url, download_path, archive_name.has_value(), tool_dir_path, sha512};
#endif
}