aboutsummaryrefslogtreecommitdiff
path: root/toolsrc/src
diff options
context:
space:
mode:
authorras0219 <533828+ras0219@users.noreply.github.com>2020-12-08 10:46:46 -0800
committerGitHub <noreply@github.com>2020-12-08 10:46:46 -0800
commitacb6b10e7fdf5e8519c18398d0b069e1d58ca025 (patch)
treebe29b609fb2cc5097d04781b54d552982c8bda02 /toolsrc/src
parent1338ab57719bdcc3a1ddd49ef2d2af0174acc316 (diff)
downloadvcpkg-acb6b10e7fdf5e8519c18398d0b069e1d58ca025.tar.gz
vcpkg-acb6b10e7fdf5e8519c18398d0b069e1d58ca025.zip
[vcpkg] Fix uploading to Azure DevOps Artifacts (#14952)
Diffstat (limited to 'toolsrc/src')
-rw-r--r--toolsrc/src/vcpkg/binarycaching.cpp81
1 files changed, 46 insertions, 35 deletions
diff --git a/toolsrc/src/vcpkg/binarycaching.cpp b/toolsrc/src/vcpkg/binarycaching.cpp
index 966c2e77b..c73e789d0 100644
--- a/toolsrc/src/vcpkg/binarycaching.cpp
+++ b/toolsrc/src/vcpkg/binarycaching.cpp
@@ -378,6 +378,45 @@ namespace
{
}
+ int run_nuget_commandline(const std::string& cmdline)
+ {
+ if (m_interactive)
+ {
+ return System::cmd_execute(cmdline);
+ }
+
+ auto res = System::cmd_execute_and_capture_output(cmdline);
+ if (Debug::g_debugging)
+ {
+ System::print2(res.output);
+ }
+ if (res.output.find("Authentication may require manual action.") != std::string::npos)
+ {
+ System::print2(System::Color::warning,
+ "One or more NuGet credential providers requested manual action. Add the binary "
+ "source 'interactive' to allow interactivity.\n");
+ }
+ else if (res.output.find("Response status code does not indicate success: 401 (Unauthorized)") !=
+ std::string::npos &&
+ res.exit_code != 0)
+ {
+ System::print2(System::Color::warning,
+ "One or more NuGet credential providers failed to authenticate. See "
+ "https://github.com/Microsoft/vcpkg/tree/master/docs/users/binarycaching.md for "
+ "more details on how to provide credentials.\n");
+ }
+ else if (res.output.find("for example \"-ApiKey AzureDevOps\"") != std::string::npos)
+ {
+ auto res2 = System::cmd_execute_and_capture_output(cmdline + " -ApiKey AzureDevOps");
+ if (Debug::g_debugging)
+ {
+ System::print2(res2.output);
+ }
+ return res2.exit_code;
+ }
+ return res.exit_code;
+ }
+
void prefetch(const VcpkgPaths& paths, std::vector<const Dependencies::InstallPlanAction*>& actions) override
{
if (m_read_sources.empty() && m_read_configs.empty()) return;
@@ -482,19 +521,7 @@ namespace
[&] {
generate_packages_config();
- if (Debug::g_debugging)
- System::cmd_execute(cmdline);
- else
- {
- auto res = System::cmd_execute_and_capture_output(cmdline);
- if (res.output.find("Authentication may require manual action.") != std::string::npos)
- {
- System::print2(
- System::Color::warning,
- "One or more NuGet credential providers requested manual action. Add the binary "
- "source 'interactive' to allow interactivity.\n");
- }
- }
+ run_nuget_commandline(cmdline);
}();
Util::erase_remove_if(nuget_refs, [&](const std::pair<PackageSpec, NugetReference>& nuget_ref) -> bool {
@@ -555,12 +582,7 @@ namespace
.string_arg("-ForceEnglishOutput");
if (!m_interactive) cmdline.string_arg("-NonInteractive");
- auto pack_rc = [&] {
- if (Debug::g_debugging)
- return System::cmd_execute(cmdline);
- else
- return System::cmd_execute_and_capture_output(cmdline).exit_code;
- }();
+ auto pack_rc = run_nuget_commandline(cmdline.extract());
if (pack_rc != 0)
{
@@ -585,12 +607,7 @@ namespace
System::print2("Uploading binaries for ", spec, " to NuGet source ", write_src, ".\n");
- auto rc = [&] {
- if (Debug::g_debugging)
- return System::cmd_execute(cmd);
- else
- return System::cmd_execute_and_capture_output(cmd).exit_code;
- }();
+ auto rc = run_nuget_commandline(cmd.extract());
if (rc != 0)
{
@@ -617,12 +634,7 @@ namespace
System::print2(
"Uploading binaries for ", spec, " using NuGet config ", fs::u8string(write_cfg), ".\n");
- auto rc = [&] {
- if (Debug::g_debugging)
- return System::cmd_execute(cmd);
- else
- return System::cmd_execute_and_capture_output(cmd).exit_code;
- }();
+ auto rc = run_nuget_commandline(cmd.extract());
if (rc != 0)
{
@@ -1176,13 +1188,12 @@ void vcpkg::help_topic_binary_caching(const VcpkgPaths&)
{
HelpTableFormatter tbl;
tbl.text("Vcpkg can cache compiled packages to accelerate restoration on a single machine or across the network."
- " This functionality is currently enabled by default and can be disabled by either passing "
- "`--no-binarycaching` to every vcpkg command line or setting the environment variable "
- "`VCPKG_FEATURE_FLAGS` to `-binarycaching`.");
+ " By default, vcpkg will save builds to a local machine cache. This can be disabled by passing "
+ "`--binarysource=clear` as the last option on the command line.");
tbl.blank();
tbl.blank();
tbl.text(
- "Once caching is enabled, it can be further configured by either passing `--binarysource=<source>` options "
+ "Binary caching can be further configured by either passing `--binarysource=<source>` options "
"to every command line or setting the `VCPKG_BINARY_SOURCES` environment variable to a set of sources (Ex: "
"\"<source>;<source>;...\"). Command line sources are interpreted after environment sources.");
tbl.blank();