Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix MSBuildDeps sep #17901

Merged
merged 1 commit into from
Mar 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions conan/tools/microsoft/msbuilddeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
VALID_LIB_EXTENSIONS = (".so", ".lib", ".a", ".dylib", ".bc")


class MSBuildDeps(object):
class MSBuildDeps:
"""
MSBuildDeps class generator
conandeps.props: unconditional import of all *direct* dependencies only
Expand Down Expand Up @@ -167,7 +167,7 @@ def escape_path(path):
# https://docs.microsoft.com/en-us/visualstudio/msbuild/
# how-to-escape-special-characters-in-msbuild
# https://docs.microsoft.com/en-us/visualstudio/msbuild/msbuild-special-characters
return path.replace("\\", "/").lstrip("/")
return path.lstrip("/")

def join_paths(paths):
# TODO: ALmost copied from CMakeDeps TargetDataContext
Expand Down
30 changes: 12 additions & 18 deletions test/integration/toolchains/microsoft/test_msbuilddeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,14 @@ def generate(self):
ms.platform = self.options.platform
ms.generate()
""")

# Remove custom set of keys to test default values
app = app.replace(f'ms.configuration_key = "{config_key}"', "") if config_key is None else app
app = app.replace(f'ms.platform_key = "{platform_key}"', "") if platform_key is None else app
config_key_expected = "Configuration" if config_key is None else config_key
platform_key_expected = "Platform" if platform_key is None else platform_key
client.save({"app/conanfile.py": app,

client.save({"app/conanfile.py": app,
"lib/conanfile.py": GenConanfile("lib", "0.1").with_package_type("header-library")})
client.run("create lib")
client.run(f'install app -s build_type={build_type} -s arch={arch} -o *:platform={exp_platform} -o *:configuration="{configuration}"')
Expand Down Expand Up @@ -181,18 +181,12 @@ def package_info(self):
def test_msbuilddeps_relocatable(withdepl):
c = TestClient()
c.save({
"libh/conanfile.py": GenConanfile("libh", "0.1")
.with_package_type("header-library"),
"libs/conanfile.py": GenConanfile("libs", "0.2")
.with_package_type("static-library")
.with_requires("libh/0.1"),
"libd/conanfile.py": GenConanfile("libd", "0.3")
.with_package_type("shared-library"),
"app/conanfile.py": GenConanfile()
.with_requires("libh/0.1")
.with_requires("libs/0.2")
.with_requires("libd/0.3")
.with_settings("arch", "build_type"),
"libh/conanfile.py": GenConanfile("libh", "0.1").with_package_type("header-library"),
"libs/conanfile.py": GenConanfile("libs", "0.2").with_package_type("static-library")
.with_requires("libh/0.1"),
"libd/conanfile.py": GenConanfile("libd", "0.3").with_package_type("shared-library"),
"app/conanfile.py": GenConanfile().with_requires("libh/0.1", "libs/0.2", "libd/0.3")
.with_settings("arch", "build_type"),
})

c.run("create libh")
Expand All @@ -206,7 +200,7 @@ def test_msbuilddeps_relocatable(withdepl):
value = text.split(f"<{marker}>")[1].split(f"</{marker}>")[0]
if withdepl:
# path should be relative, since artifacts are moved along with project
prefix = '$(MSBuildThisFileDirectory)/'
prefix = '$(MSBuildThisFileDirectory)\\'
assert value.startswith(prefix)
tail = value[len(prefix):]
assert not os.path.isabs(tail)
Expand All @@ -222,5 +216,5 @@ def test_msbuilddeps_relocatable(withdepl):
for fn in propsfiles:
text = c.load(fn)
text = text.replace('\\', '/')
dir = c.current_folder.replace('\\', '/')
assert dir not in text
folder = c.current_folder.replace('\\', '/')
assert folder not in text