mstorsjo / msvc-wine

Scripts for setting up and running MSVC in Wine on Linux
Other
683 stars 83 forks source link

msbuild: Set UseEnv variable to true #151

Closed TheComputerGuy96 closed 1 week ago

TheComputerGuy96 commented 1 week ago

For some reason default Windows headers and libraries can't be found in an older project without those variables being set

ravenexp commented 1 week ago

@ravenexp - Do you have any opinions on this?

These variables look like something the MSVC property files for C++ projects would set internally. See for example MSBuild/Microsoft/VC/v170/Microsoft.Cpp.MSVC.Toolset.Win32.props.

Rather than overriding these globally, I'd first check if setting UseEnv solves the problem for the project in question:

https://learn.microsoft.com/en-us/cpp/build/reference/msbuild-visual-cpp-overview?view=msvc-170#useenv-property

@TheComputerGuy96

Does

msbuild /p:UseEnv=true

work for your project?

TheComputerGuy96 commented 1 week ago

@ravenexp UseEnv=true also works (so I set that by default instead)

ravenexp commented 1 week ago

@ravenexp UseEnv=true also works (so I set that by default instead)

It's great that it works, but it should not be set by default because it effectively bypasses all configuration settings from the MSBuild project file.

Can you share your MSBuild project file or maybe just the configuration properties part without the source file names? I'll try to figure out what is missing from the msvc-wine MSBuild environment. I want to try to get to the root cause of this issue.

TheComputerGuy96 commented 1 week ago

@ravenexp Here's the .vcxproj file: https://github.com/CookiePLMonster/SilentPatch/blob/dev/DDraw/DDraw.vcxproj

ravenexp commented 1 week ago

Ah, this must be it:

<PlatformToolset>v141_xp</PlatformToolset>

I've never tried targeting Windows 7, much less XP. I'll try to figure out what env vars are required to support this platform.

TheComputerGuy96 commented 1 week ago

I'm currently setting /p:PlatformToolset=v143 option to make that project build (and the SetEnv option of course)

ravenexp commented 1 week ago

I'm currently setting /p:PlatformToolset=v143 option to make that project build (and the SetEnv option of course)

I've opened https://github.com/mstorsjo/msvc-wine/pull/152 to address the root cause of this bug. With it applied, your project should now build with:

msbuild /p:Platform=Win32 /p:PlatformToolset=v143 /p:WindowsTargetPlatformVersion=10.0

UseEnv is not required.

TheComputerGuy96 commented 1 week ago

@ravenexp I can confirm that MR solves the issue too (with that extra /p:WindowsTargetPlatformVersion=10.0 option; otherwise I get the same build error)

ravenexp commented 1 week ago

@ravenexp I can confirm that MR solves the issue too (with that extra /p:WindowsTargetPlatformVersion=10.0 option; otherwise I get the same build error)

Then I suggest closing this in favor of #152, which solves the actual problem that prevented the needed WindowsTargetPlatformVersion override from working in msvc-wine.

TheComputerGuy96 commented 1 week ago

Superseeded by #152