dotnet / dotnet/msbuild

SetPlatform Negotiation - Allow AnyCPU projects to resolve specific platform references

Open
#6,897 6 comments 0 reactions 0 assignees View on GitHub
Area: SetPlatform triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 13h
Merged PRs (30d)
133

Description

The [SetPlatform Negotiation feature](https://github.com/dotnet/msbuild/blob/main/documentation/ProjectReference-Protocol.md#setplatform-negotiation) does not work "out-of-the-box" if there is an `AnyCPU` project that references a specific platform (`x86`/`x64`) project. For example, the following combination of projects will fail (or possibly fallback to a default platform):

ProjectA [x86/x64] -> ProjectB [AnyCPU] -> ProjectC [x86/x64]

In this case, it would be ideal if ProjectB could infer that it should build ProjectC as either `x86` or `x64`.

_Note: In real-world scenarios, ProjectC is generally forced to be both x86 / x64 in order to accommodate a third-party native wrapper._

**Additional Context:** Created issue based on this [comment](https://github.com/dotnet/msbuild/pull/6889#issuecomment-928288809) from @BenVillalobos in #6889.

**Discussion Point:** As mentioned by @AArnott [here](https://github.com/dotnet/msbuild/pull/6889#issuecomment-928349112), you will generally get a processor architecture mismatch warning when building the specified project chain (but it does work). To address that warning (without working around it via setting the [ResolveAssemblyWarnOrErrorOnTargetArchitectureMismatch](https://github.com/dotnet/msbuild/blob/3a1e456fe227f3e2b190b434578844c31e8bcb4a/src/Tasks/Microsoft.Common.CurrentVersion.targets#L2277) property) requires ALL projects to have both `x86` and `x64` platform configurations. This in turn means that you have to build everything twice to support your dual `x86` and `x64` build…which isn't ideal for really large codebases.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.