conan-io / conan

Conan - The open-source C and C++ package manager
https://conan.io
MIT License
7.97k stars 952 forks source link

[bug] MSBuildDeps + deployer generates props with absolute paths #16427

Closed stgatilov closed 3 weeks ago

stgatilov commented 1 month ago

Describe the bug

I use deployer to generate everything necessary for conan-less builds on other machines.

It seems that MSBuildDeps generates props with absolute paths. Here is what conan_libjpeg_vars_release_x64.props look like for me:

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup Label="ConanVariables">
    <ConanlibjpegRootFolder>D:/StevePrograms/temp3/build/full_deploy/host/libjpeg/9f/Release/x86_64</ConanlibjpegRootFolder>
    <ConanlibjpegBinaryDirectories></ConanlibjpegBinaryDirectories>
    <ConanlibjpegCompilerFlags></ConanlibjpegCompilerFlags>
    <ConanlibjpegLinkerFlags></ConanlibjpegLinkerFlags>
    <ConanlibjpegPreprocessorDefinitions>LIBJPEG_STATIC;</ConanlibjpegPreprocessorDefinitions>
    <ConanlibjpegIncludeDirectories>$(ConanlibjpegRootFolder)/include;</ConanlibjpegIncludeDirectories>
    <ConanlibjpegResourceDirectories>$(ConanlibjpegRootFolder)/res;</ConanlibjpegResourceDirectories>
    <ConanlibjpegLibraryDirectories>$(ConanlibjpegRootFolder)/lib;</ConanlibjpegLibraryDirectories>
    <ConanlibjpegLibraries>libjpeg.lib;</ConanlibjpegLibraries>
    <ConanlibjpegSystemLibs></ConanlibjpegSystemLibs>
  </PropertyGroup>
</Project>

CMakeDeps generates correct path relative to ${CMAKE_CURRENT_LIST_DIR}. By the way, if I manually make path relative to $(MSBuildThisFileDirectory), then Visual Studio finds the file properly.

I use conan version is 2.3.1.

How to reproduce it

Create conanfile.txt with MSBuildDeps generator, then execute:

conan install . -of build -s build_type=Release -d full_deploy

Inspect props files in build folder.

memsharded commented 1 month ago

Hi @stgatilov

Thanks for your report.

As commented in https://docs.conan.io/2/examples/extensions/deployers/dev/development_deploy.html, this wouldn't be a bug, but the relocatable deployments are only supported at this moment by CMake integrations, but not MSBuild ones:

Only CMakeDeps and CMakeToolchain are relocatable at this moment. For other build system integrations, please create a ticket in Github

It seems that with $(MSBuildThisFileDirectory) it should be relatively easy to implement this, lets try to do it.

Would you like to try to submit a Pull Request yourself?

stgatilov commented 1 month ago

Oh, this is indeed a feature request then.

I can try to make a PR myself. But I must admit I never worked on serious Python projects, so it would certainly take some time.

memsharded commented 1 month ago

I can try to make a PR myself. But I must admit I never worked on serious Python projects, so it would certainly take some time.

Don't worry, we can do it ourselves, it was just if you enjoyed doing it and it wasn't a big effort for you. So as you wish 🙂