-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Platform Negotiation fails between two projects that offer the same platform #7760
Comments
I'm not able to repro what you're seeing. Are the projects set up properly? It looks like neither project has a default platform, should the command line repro be What's happening is that during the Because of that, platform negotiation improperly detects arm64 as what lib1 would have built as, but as it builds it defaults to anycpu instead. My next question, can we make this MSBuild call explicitly not pass any properties? This target does not rely on msbuild/src/Tasks/Microsoft.Common.CurrentVersion.targets Lines 1776 to 1786 in 62b690b
Option number 2 is to separate MSBuild calls got |
Yes, I believe you're right in that I dropped that switch from the repro steps. I've corrected the issue description. |
…rks (#7803) Fixes #7760 Context #7511 figured out a better way to prevent over-evaluations when A(Platform=x86) -> B(Platform=x86, Platforms=x64,x86). It allowed setplatform negotiation to check "would project B have built as what A is currently building as if we didn't tell it anything? Unfortunately, there's a bug when passing a global property because GetTargetFrameworks passes Platform and Configuration, despite not needing to. This PR is an attempt at resolving this by no longer passing those properties, as well as undefining them. Changes Made Remove additional properties during the MSBuild call to GetTargetFrameworks. Testing Notes It's possible we can't fix it this way, and instead we'll need to create two msbuild calls. One that's the standard but only gets called when EnableDynamicPlatformResolution is false, and the other that only gets called when EnableDynamicPlatformResolution is true.
Reactivating as @benvillalobos requested, given I have more cases of P2P graphs that fail. Not all align exactly with the original issue, and we can certainly farm them out to distinct new issues if that's helpful. These repro with:
Newly discovered cases:
High level requirements that I think fall out from these repro cases include:
|
I would further suggest that the proposed traversal project capability of building all platforms of referenced projects should be exposed as metadata on a <ProjectReference Include="some.proj">
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<AllPlatforms>true</AllPlatforms>
</ProjectReference> This would allow other project types such as setup/archival projects to build all platforms of a referenced project and consume their outputs in whatever way they need. Alternatively, the metadata could be a semicolon-delimited list of platforms that should be built for that project. But if so, some special value (e.g. |
This is an interesting scenario. The As for the second scenario:
I think this is no longer the case. Testing it out today, the anycpulib detects that the multiplat csproj would have built as AnyCPU without passing global properties, so it doesn't explicitly pass Have you tested that scenario with an MSBuild that has https://github.com/dotnet/msbuild/pull/7511/files#diff-5407d46dd30ce4031e530c35cc2e0a62a6c96e54cb1def14fb316f351ef92de9 merged? |
What version of the .NET SDK does or will carry the msbuild that contains the fix? |
92e0776 should have that change. Does the issue persist into the 7.0 SDK's? Is it possible for you to use the 7.0 SDK's? |
The 7.0.100-rc.1.22431.12 .NET SDK works. But 6.0.401 (which carries msbuild 17.3.1+2badb37d1) does not. Using the 7.0 SDK is only an option for me once it ships as a stable version. |
@AArnott I just tested this with 6.0.402 and I see only one build of the multiplatcsproj, and one reduced evaluation (compared to 6.0.300 from globaljson). I think your global json may have been pinning you to to a previous version:
|
Looks good at this point. Thank you. |
Issue Description
When library A references library B, and both support arm64 as a platform, building library A for arm64 should also build library B for arm64. But instead, library B builds for AnyCPU.
Steps to Reproduce
Check out this minimal repro:
platformnegotiation.zip
Run
dotnet build lib2 /p:platform=arm64
and see how only lib2 builds for arm64 while lib1 (which lib2 references) builds for AnyCPU.Expected Behavior
Note the
arm64
in the lib1 output path.Actual Behavior
Note the lack of the
arm64
in the output path.Analysis
When the
_GetProjectReferencePlatformProperties
target determines that a referenced project supports an exact match with the originating project, it thinks it can just drop the need to set the Platform (because it would propagate naturally, I guess):But it doesn't work, because when the ProjectReference is ultimately built, it's passed with this metadata:
That means the Platform property won't propagate. As a result, the referenced project will build with its default Platform instead of the matching one.
Versions & Configurations
This is with .NET SDK 7.0.100-preview.5.22307.18.
Note that this is impacting work that targets a .NET 6 SDK.
The text was updated successfully, but these errors were encountered: