Extract create_user_troubleshooting_message(). CI doesn't call it, interactive commands do
MODIFY
include/vcpkg_Commands.h
include/vcpkg_Commands.h
@@ -23,6 +23,7 @@ namespace vcpkg::Commands
const std::string& to_string(const BuildResult build_result);
std::string create_error_message(const BuildResult build_result, const std::string& package_id);
+ std::string create_user_troubleshooting_message(const package_spec& spec);
BuildResult build_package(const SourceParagraph& source_paragraph, const package_spec& spec, const vcpkg_paths& paths, const fs::path& port_dir, const StatusParagraphs& status_db);
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet);

MODIFY
src/commands_build.cpp
src/commands_build.cpp
@@ -56,14 +56,6 @@ namespace vcpkg::Commands::Build
if (return_code != 0)
{
- System::println(System::color::error, "Error: building package %s failed", spec.toString());
- System::println("Please ensure sure you're using the latest portfiles with `vcpkg update`, then\n"
- "submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n"
- " Package: %s\n"
- " Vcpkg version: %s\n"
- "\n"
- "Additionally, attach any relevant sections from the log files above."
- , spec.toString(), Info::version());
TrackProperty("error", "build failed");
TrackProperty("build_error", spec.toString());
return BuildResult::BUILD_FAILED;
@@ -108,6 +100,17 @@ namespace vcpkg::Commands::Build
return Strings::format("Error: Building package %s failed with: %s", package_id, Build::to_string(build_result));
}
+ std::string create_user_troubleshooting_message(const package_spec& spec)
+ {
+ return Strings::format("Please ensure sure you're using the latest portfiles with `vcpkg update`, then\n"
+ "submit an issue at https://github.com/Microsoft/vcpkg/issues including:\n"
+ " Package: %s\n"
+ " Vcpkg version: %s\n"
+ "\n"
+ "Additionally, attach any relevant sections from the log files above."
+ , spec.toString(), Info::version());
+ }
+
void perform_and_exit(const vcpkg_cmd_arguments& args, const vcpkg_paths& paths, const triplet& default_target_triplet)
{
static const std::string example = Commands::Help::create_example_string("build zlib:x64-windows");
@@ -165,6 +168,7 @@ namespace vcpkg::Commands::Build
if (result != BuildResult::SUCCEEDED)
{
System::println(System::color::error, Build::create_error_message(result, spec.toString()));
+ System::println(Build::create_user_troubleshooting_message(spec));
exit(EXIT_FAILURE);
}

MODIFY
src/commands_build_external.cpp
src/commands_build_external.cpp
@@ -27,6 +27,7 @@ namespace vcpkg::Commands::BuildExternal
if (result != Build::BuildResult::SUCCEEDED)
{
System::println(System::color::error, Build::create_error_message(result, spec->toString()));
+ System::println(Build::create_user_troubleshooting_message(*spec));
exit(EXIT_FAILURE);
}

MODIFY
src/commands_install.cpp
src/commands_install.cpp
@@ -218,6 +218,7 @@ namespace vcpkg::Commands::Install
if (result != Build::BuildResult::SUCCEEDED)
{
System::println(System::color::error, Build::create_error_message(result, action.spec.toString()));
+ System::println(Build::create_user_troubleshooting_message(action.spec));
exit(EXIT_FAILURE);
}
const BinaryParagraph bpgh = try_load_cached_package(paths, action.spec).get_or_throw();

Extract create_user_troubleshooting_message(). CI doesn't call it, interactive commands do