From 7a60623866146d89296755e43217c73594fe8cb0 Mon Sep 17 00:00:00 2001 From: SpaceIm <30052553+SpaceIm@users.noreply.github.com> Date: Sat, 31 Dec 2022 15:12:10 +0100 Subject: [PATCH] MSBuild: ensure to consume props files generated by MSBuildToolchain & MSBuildDeps with highest precedence --- conan/tools/microsoft/msbuild.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/conan/tools/microsoft/msbuild.py b/conan/tools/microsoft/msbuild.py index e7a8df5fb37..80c2801e20a 100644 --- a/conan/tools/microsoft/msbuild.py +++ b/conan/tools/microsoft/msbuild.py @@ -1,3 +1,5 @@ +import os + from conans.errors import ConanException @@ -46,6 +48,15 @@ def command(self, sln, targets=None): raise ConanException("targets argument should be a list") cmd += " /target:{}".format(";".join(targets)) + props_paths = [] + for props_file in ("conantoolchain.props", "conandeps.props"): + props_path = os.path.join(self._conanfile.generators_folder, props_file) + if os.path.exists(props_path): + props_paths.append(props_path) + if props_paths: + props_paths = ";".join(props_paths) + cmd += f" /p:ForceImportBeforeCppTargets=\"{props_paths}\"" + return cmd def build(self, sln, targets=None):