-
Notifications
You must be signed in to change notification settings - Fork 991
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
[question] What is the equivalent of conans.tools.MSBuild.build()
upgrade_project
in conan.tools.microsoft.MSBuid
?
#12155
Comments
conans.tools.MSBuild
upgrade_project
in conan.tools.microsoft.MSBuid
?conans.tools.MSBuild.build()
upgrade_project
in conan.tools.microsoft.MSBuid
?
I had to write something like this in def _fix_msvc_platform_toolset(self, vcxproj_file, old_toolset):
platform_toolset = {
"Visual Studio": {
"8": "v80",
"9": "v90",
"10": "v100",
"11": "v110",
"12": "v120",
"14": "v140",
"15": "v141",
"16": "v142",
"17": "v143",
},
"msvc": {
"170": "v110",
"180": "v120",
"190": "v140",
"191": "v141",
"192": "v142",
"193": "v143",
}
}.get(str(self.settings.compiler)).get(str(self.settings.compiler.version))
replace_in_file(
self,
vcxproj_file,
f"<PlatformToolset>{old_toolset}</PlatformToolset>",
f"<PlatformToolset>{platform_toolset}</PlatformToolset>",
) then: if (self.settings.compiler == "Visual Studio" and Version(self.settings.compiler) >= "15") or \
(self.settings.compiler == "msvc" and Version(self.settings.compiler) >= "191"):
msvc_version = "vs2017"
old_toolset = "v141"
else:
msvc_version = "vs2013"
old_toolset = "v120"
build_script_folder = os.path.join(self.source_folder, "windows", msvc_version)
self._fix_msvc_platform_toolset(os.path.join(build_script_folder, "liblzma.vcxproj"), old_toolset)
self._fix_msvc_platform_toolset(os.path.join(build_script_folder, "liblzma_dll.vcxproj"), old_toolset) But it doesn't scale (need a recipe update for each new Visual Studio release), and conan already has all this information. A helper function could provide platform toolset associated with a given Visual Studio version. |
The platform toolset is already defined in the provided .props file by |
It's overridden in vcxproj files (as well as runtime & debug/release configurations). https://github.com/xz-mirror/xz/blob/v5.2.5/windows/vs2017/xz_win.sln It's not clear to me what are good sln / vcxproj files contents |
This is what I mean, there are tests that have the PlatformToolset defined, like
conan_toolchain.props file, not the opposite.Is the toolchain being injected in the vcxproj? Something like:
|
Good question, I don't think so. How this magic is supposed to happen? Do we have to programmatically edit vcxproj files in recipes with this content? I was naively thinking that having MSBuildToolchain in generate(), and MSBuild in build() (with proper sln file given as argument) was sufficient like all other Toolchain / build helper combo like CMake, Meson or Autotools. |
Could it come from the fact that I've not used Do I have to move generators folder under the same folder than sln file? EDIT: no, doesn't work either. |
My understanding of https://learn.microsoft.com/fr-fr/cpp/build/project-property-inheritance?view=msvc-170 is that properties in vcxproj files have precedence over .props files. |
Yes, it is necessary to inject the .props files, for third-party vcxproj, I guess it is necessary to apply a patch
Yes, layout is not enough
This is what the test covers, and seems if you do the inclusion after the properties declaration in vcxproj, it works |
Ok, so unlike all other toolchain helpers in conan v2, MSBuildToolchain is intrusive, correct? It won't be easy to edit CCI recipes relying on legacy MSBuild helper. |
But the problem is this vcxproj has another logic to designate Configuration name. I guess it can be edited, but it's ugly. We have to:
It won't scale. I guess in this recipe it would be easier to not use MSBuildToolchain & set msbuild.build_type to Anyway programmatically edit a vcxproj file is very cumbersome, nobody will want to maintain such recipes. |
@memsharded I'm wondering if |
I don't know whether current tests properly cover everything, but #12817 is required to avoid to patch MSBuild files in real projects (like libsodium & xz_utils). Beyond that manual patch is tedious, location of manual injection of these props is very important, so not something you want to delegate to users. Also something I've learned, is that recipes have to be very careful with Quite tricky, in
|
To build
xz_utils/5.2.5
with Visual Studio 2022 in conan-io/conan-center-index#13038, vcxproj file must be updated with a different Platform Toolset, how to achieve that in conan v2?(otherwise it fails with this kind of error since we try to build against a vs2017 solution:
)
The text was updated successfully, but these errors were encountered: