[CI] Fix too early deletion of files
MODIFY
src/vcpkg/build.cpp
src/vcpkg/build.cpp
@@ -399,16 +399,6 @@ namespace vcpkg::Build
}
}
- if (config.build_package_options.clean_packages == CleanPackages::YES)
- {
- auto& fs = paths.get_filesystem();
- const PackageSpec spec = PackageSpec::from_name_and_triplet(config.scf.core_paragraph->name, config.triplet)
- .value_or_exit(VCPKG_LINE_INFO);
- const fs::path package_dir = paths.package_dir(spec);
- std::error_code ec;
- fs.remove_all(package_dir, ec);
- }
-
return result;
}

MODIFY
src/vcpkg/install.cpp
src/vcpkg/install.cpp
@@ -308,6 +308,15 @@ namespace vcpkg::Install
auto bcf = std::make_unique<BinaryControlFile>(
Paragraphs::try_load_cached_control_package(paths, action.spec).value_or_exit(VCPKG_LINE_INFO));
auto code = aux_install(display_name_with_features, *bcf);
+
+ if (action.build_options.clean_packages == Build::CleanPackages::YES)
+ {
+ auto& fs = paths.get_filesystem();
+ const fs::path package_dir = paths.package_dir(action.spec);
+ std::error_code ec;
+ fs.remove_all(package_dir, ec);
+ }
+
return {code, std::move(bcf)};
}

[CI] Fix too early deletion of files