microsoft / MSBuildSdks

MSBuild project SDKs
MIT License
449 stars 80 forks source link

Microsoft.Build.Traversal ProjectReference built Platform mismatch #533

Closed AliveDevil closed 7 months ago

AliveDevil commented 7 months ago

In a csproj referencing a vcxproj may result in mismatched platforms being built (Platform flows from csproj to vcxproj, Platform is deleted).

Repro: traversal-test.zip

Run

msbuild /Restore /bl dirs.proj

Observe that in artifacts\bin\Shared\ three folders are created - "Release", "Win32", "x64". Release was created (check binlog) by the project dependency in csproj, when built with Platform=x86 Win32 was created from dirs.proj where Platform=Win32 x64 was created from dirs.proj and not rebuilt from csproj where Platform=x64. With EnableDynamicPlatformResolution=False the output is created in artifacts\bin\Shared\x86 which is wrong as well.

Running

msbuild /Restore /bl /p:Platform=x86 traversal-test.sln

Does not create the erroneous artifacts\bin\Shared\Release-folder.

How can I stop MSBuild from creating the (probably AnyCPU) Release-folder? Checking the binlog I found Target Name=_GetProjectReferencePlatformProperties Project=app.csproj adding _MSBuildProjectReferenceExistent with UndefineProperties = ;TargetFramework;TargetFramework;RuntimeIdentifier;SelfContained;Platform.

AliveDevil commented 7 months ago

Moved to https://github.com/dotnet/msbuild/issues/9712.