binarycaching: Add NuGet timeout configuration entry
* binarycaching: Default NuGet push timeout to one hour
Needs the extra second due to some potential issue with how NuGet
calculates the timeout:
* Use configuration setting for timeout value
MODIFY
src/vcpkg-test/configparser.cpp
src/vcpkg-test/configparser.cpp
@@ -104,6 +104,42 @@ TEST_CASE ("BinaryConfigParser nuget source provider", "[binaryconfigparser]")
}
}
+TEST_CASE ("BinaryConfigParser nuget timeout", "[binaryconfigparser]")
+{
+ {
+ auto parsed = create_binary_provider_from_configs_pure("nugettimeout,3601", {});
+ REQUIRE(parsed.has_value());
+ }
+ {
+ auto parsed = create_binary_provider_from_configs_pure("nugettimeout", {});
+ REQUIRE(!parsed.has_value());
+ }
+ {
+ auto parsed = create_binary_provider_from_configs_pure("nugettimeout,", {});
+ REQUIRE(!parsed.has_value());
+ }
+ {
+ auto parsed = create_binary_provider_from_configs_pure("nugettimeout,nonsense", {});
+ REQUIRE(!parsed.has_value());
+ }
+ {
+ auto parsed = create_binary_provider_from_configs_pure("nugettimeout,0", {});
+ REQUIRE(!parsed.has_value());
+ }
+ {
+ auto parsed = create_binary_provider_from_configs_pure("nugettimeout,12x", {});
+ REQUIRE(!parsed.has_value());
+ }
+ {
+ auto parsed = create_binary_provider_from_configs_pure("nugettimeout,-321", {});
+ REQUIRE(!parsed.has_value());
+ }
+ {
+ auto parsed = create_binary_provider_from_configs_pure("nugettimeout,321,123", {});
+ REQUIRE(!parsed.has_value());
+ }
+}
+
TEST_CASE ("BinaryConfigParser nuget config provider", "[binaryconfigparser]")
{
{

MODIFY
src/vcpkg/binarycaching.cpp
src/vcpkg/binarycaching.cpp
@@ -543,11 +543,13 @@ namespace
std::vector<std::string>&& write_sources,
std::vector<path>&& read_configs,
std::vector<path>&& write_configs,
+ std::string&& timeout,
bool interactive)
: m_read_sources(std::move(read_sources))
, m_write_sources(std::move(write_sources))
, m_read_configs(std::move(read_configs))
, m_write_configs(std::move(write_configs))
+ , m_timeout(std::move(timeout))
, m_interactive(interactive)
, m_use_nuget_cache(false)
{
@@ -815,6 +817,8 @@ namespace
.string_arg("push")
.path_arg(nupkg_path)
.string_arg("-ForceEnglishOutput")
+ .string_arg("-Timeout")
+ .string_arg(m_timeout)
.string_arg("-Source")
.string_arg(write_src);
@@ -844,6 +848,8 @@ namespace
.string_arg("push")
.path_arg(nupkg_path)
.string_arg("-ForceEnglishOutput")
+ .string_arg("-Timeout")
+ .string_arg(m_timeout)
.string_arg("-ConfigFile")
.path_arg(write_cfg);
if (!m_interactive)
@@ -876,6 +882,7 @@ namespace
std::vector<path> m_write_configs;
std::set<PackageSpec> m_restored;
+ std::string m_timeout;
bool m_interactive;
bool m_use_nuget_cache;
};
@@ -1130,6 +1137,7 @@ namespace
{
bool m_cleared = false;
bool interactive = false;
+ std::string nugettimeout = "100";
std::vector<path> archives_to_read;
std::vector<path> archives_to_write;
@@ -1152,6 +1160,7 @@ namespace
{
m_cleared = true;
interactive = false;
+ nugettimeout = "100";
archives_to_read.clear();
archives_to_write.clear();
url_templates_to_get.clear();
@@ -1274,6 +1283,32 @@ namespace
segments[3].first);
}
}
+ else if (segments[0].second == "nugettimeout")
+ {
+ if (segments.size() != 2)
+ {
+ return add_error(
+ "expected arguments: binary config 'nugettimeout' expects a single positive integer argument");
+ }
+
+ auto&& t = segments[1].second;
+ if (t.empty())
+ {
+ return add_error(
+ "unexpected arguments: binary config 'nugettimeout' requires non-empty nugettimeout");
+ }
+ char* end;
+ long timeout = std::strtol(t.c_str(), &end, 0);
+ if (*end != '\0')
+ {
+ return add_error("invalid value: binary config 'nugettimeout' requires a valid integer");
+ }
+ if (timeout <= 0)
+ {
+ return add_error("invalid value: binary config 'nugettimeout' requires integers greater than 0");
+ }
+ state->nugettimeout = std::to_string(timeout);
+ }
else if (segments[0].second == "default")
{
if (segments.size() > 2)
@@ -1635,6 +1670,7 @@ ExpectedS<std::unique_ptr<IBinaryProvider>> vcpkg::create_binary_provider_from_c
std::move(s.sources_to_write),
std::move(s.configs_to_read),
std::move(s.configs_to_write),
+ std::move(s.nugettimeout),
s.interactive));
}
@@ -1826,6 +1862,9 @@ void vcpkg::help_topic_binary_caching(const VcpkgPaths&)
tbl.format("nugetconfig,<path>[,<rw>]",
"Adds a NuGet-config-file-based source; equivalent to the `-Config` parameter of the NuGet CLI. This "
"config should specify `defaultPushSource` for uploads.");
+ tbl.format("nugettimeout,<seconds>",
+ "Specifies a nugettimeout for NuGet network operations; equivalent to the `-Timeout` parameter of the "
+ "NuGet CLI.");
tbl.format("x-azblob,<url>,<sas>[,<rw>]",
"**Experimental: will change or be removed without warning** Adds an Azure Blob Storage source. Uses "
"Shared Access Signature validation. URL should include the container path.");

binarycaching: Add NuGet timeout configuration entry (#95)

* binarycaching: Default NuGet push timeout to one hour

Needs the extra second due to some potential issue with how NuGet
calculates the timeout:
https://jfrog.com/knowledge-base/how-to-resolve-nuget-push-failures-after-5-minutes-even-though-timeout-value-is-set-as-greater-than-5-minutes-300-seconds/

* Use configuration setting for timeout value