-
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
Failure in project reference target framework negotiation when ProjectReference items are duplicated #2688
Comments
@AndyGerlicher I'm not sure how important it is that a project with duplicate references build successfully, but I think we should at least have a good error message. Right now the failure mode has no relation to the root cause of the problem, and it was very difficult for @nguerrera and I to diagnose it. |
This issue no more repro on windows with latest dotnet cli(.NET Command Line Tools (2.2.0-preview1-007853)). But on Ubuntu it is still causing build failure. It will be very helpful if the error indicates the actual csproj rather than the projects referenced. |
Just a note that it is also possible for this to manifest with failure to write to a file in use. |
We've just been hitting this as well, really confusing. Our Windows builds were fine when we added a duplicate project reference (one hard-coded in our config - the other generated from other tooling we've built). However, it was failing to resolve properly on linux in our GitHub Actions CI on Ubuntu with In case it helps in the future looking at the binlog (attached msbuild.zip) it was found as a Project Reference in the evaluation phase here (the Converters/src project): But then missing in the So slightly different behavior than the original poster here, but end result of duplicated ProjectReference in project on a dotnet build on linux doesn't work, where same code/setup on Windows has no issues. |
dotnet build on linux doesn't like duplicated ProjectReference, left note for future See dotnet/msbuild#2688
dotnet build on linux doesn't like duplicated ProjectReference, left note for future See dotnet/msbuild#2688
This has larger implications on our workflow than I realized. We need to add the reference in some cases when we're not building everything for local development. However, one of the projects being built may or may not include the same project reference we need for our 'shell'. Therefore, we have no way of knowing if a duplicate |
@stan-sz not sure if a linter truly helps. In our case, we're sucking a bunch of different projects together into a larger build, some of them may have references to the same project and need them to build themselves. It's just at the parent level that we're trying to build that now thinks there are multiple references: graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
So, we can't remove the reference to D from either B or C as they need it to build. At least I think that's what still going on here and is related to this underlying issue. I'm hitting this locally now trying to build a Windows App SDK/WinUI 3 app and seeing CS1704 An assembly with the same simple name has already been imported. |
Build
A.csproj
in the below example.EXPECTED: Build succeeds
ACTUAL:
The duplicated
ProjectReference
appears to be interfering with the logic in_GetProjectReferenceTargetFrameworkProperties
which is supposed to setSetTargetFramework
on theAnnotatedProjects
.A.csproj
:B.csproj
:The text was updated successfully, but these errors were encountered: