Skip to content

support including custom property sheets with MSBuildDeps generators - #20488

Open
jdoubleu wants to merge 1 commit into
conan-io:develop2from
jdoubleu:msbuilddeps-build-modules
Open

jdoubleu wants to merge 1 commit into
conan-io:develop2from
jdoubleu:msbuilddeps-build-modules

Conversation

@jdoubleu

@jdoubleu jdoubleu commented Nov 10, 2026 •

Copy link
Copy Markdown

Changelog: Feature: Allow injecting additional property sheets into MSBuildDeps generated files
Docs: conan-io/docs#4582

Implements the feature requested in #20423. The implementation is very simple, giving recipe authors great flexibility. As outlined in #20423, the most common use-case would be to include MSBuild/Visual Studio specific files, like .natvis debugger extensions.

I'm also preparing a PR for the conan-center-index to utilize this feature in some, primarily Microsoft-related, recipes.

  • Refer to the issue that supports this Pull Request.
  • If the issue has missing info, explain the purpose/use case/pain/need that covers this Pull Request.
  • I've read the Contributing guide.
  • I've followed the PEP8 style guides for Python code.
  • I've opened another PR in the Conan docs repo to the develop2 branch, documenting this one.

Discussion

I'm not sure about the naming of the msbuild_import_props property. I started with msbuild_builds_modules to align with CMakeDeps properties but didn't find it fitting in the MSBuild context. The included files aren't necessarily limited to .props files but would also accept .target files.

@CLAassistant

CLAassistant commented Nov 10, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@memsharded memsharded left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution @jdoubleu

It would be necessary to add some tests, I'd suggest a full "functional" test that completely demoes an injection of some .props file.

return re.compile(r"[.+]").sub("_", name)

@staticmethod
def _module_path(path, name):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems this method is unused?

Comment on lines +89 to +93
<ImportGroup Label="PropertySheets">
{% for mod in build_modules %}
<Import Condition="Exists('$(Conan{{name}}RootFolder)\{{mod}}')" Project="$(Conan{{name}}RootFolder)\{{mod}}"/>
{% endfor %}
</ImportGroup>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be better if possible to follow the pattern that other variables follow:

  • Define the contents/value in the ```xxx-vars.props`` file in a new variable
  • Use the variable here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When supporting multiple include files that's not possible, unfortunately. The property would need to hold a list of files. But MSBuild doesn't allow iterating over a property at all. The Import element doesn't support a list of files. It requires one element per file.

I think I'm going to drop support for multiple files and only allow a single file to be included.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, if users want to include multiple files, they can also Import those files in their added props file I guess.

@memsharded

Copy link
Copy Markdown
Member

Hi @jdoubleu

Please let us know if you need some guidance or help with the tests or other aspects. Conan 2.35 is planned for end of the month, as usual, there is still time to get this PR into it. Thanks!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants