-
Notifications
You must be signed in to change notification settings - Fork 257
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
[Bug]: "An item with the same key has already been added" when migrating to CPM with ProjectDependencies
in solution file
#12021
Comments
@YoshiRulz I'm unable to reproduce the issue.
Can you supply a binlog by specifying the |
No because it's building correctly after a .NET SDK update. Hopefully |
repro project |
@YoshiRulz Thanks, unfortunately I'm not able to open the binlog for some reason? Does it open in the Structured Log Viewer for you? |
Ah sorry I figured out that the attachment is I believe the problem is that you're using the - <PackageVersion Update="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" />
+ <PackageVersion Include="DotNetAnalyzers.DocumentationAnalyzers" Version="1.0.0-beta.59" /> Other implementations of central package management use an |
That gives (I was confused by the one occurrence of |
@YoshiRulz you seem to have uncovered a corner case with the way NuGet gathers package references. Your solution file is declare dependencies: Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Version", "src\BizHawk.Version\BizHawk.Version.csproj", "{0CE8B337-08E3-4602-BF10-C4D4C75D2F13}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Common", "src\BizHawk.Common\BizHawk.Common.csproj", "{866F8D13-0678-4FF9-80A4-A3993FD4D8A3}"
+ ProjectSection(ProjectDependencies) = postProject
+ {0CE8B337-08E3-4602-BF10-C4D4C75D2F13} = {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}
+ EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BizHawk.Client.EmuHawk", "src\BizHawk.Client.EmuHawk\BizHawk.Client.EmuHawk.csproj", "{DD448B37-BA3F-4544-9754-5406E8094723}"
+ ProjectSection(ProjectDependencies) = postProject
+ {0CE8B337-08E3-4602-BF10-C4D4C75D2F13} = {0CE8B337-08E3-4602-BF10-C4D4C75D2F13}
+ EndProjectSection
EndProject Under normal conditions, MSBuild generates a "metaproj" project in memory from the contents of a solution file and builds that. But when your solution file declares project build ordering, it creates the metaproj in a very unique way. This is the section of the main metaproj that tells MSBuild what projects to build: <ItemGroup>
<ProjectReference Include="/home/yoshi/Downloads/hawk-cpm-repro/src/BizHawk.Version/BizHawk.Version.csproj">
<AdditionalProperties>Configuration=Debug; Platform=AnyCPU</AdditionalProperties>
<Platform>AnyCPU</Platform>
<Configuration>Debug</Configuration>
<ToolsVersion>
</ToolsVersion>
<SkipNonexistentProjects>False</SkipNonexistentProjects>
</ProjectReference>
<ProjectReference Include="/home/yoshi/Downloads/hawk-cpm-repro/src/BizHawk.Common/BizHawk.Common.csproj.metaproj">
<AdditionalProperties>Configuration=Debug; Platform=Any CPU</AdditionalProperties>
<Platform>AnyCPU</Platform>
<Configuration>Debug</Configuration>
<ToolsVersion>Current</ToolsVersion>
<SkipNonexistentProjects>Build</SkipNonexistentProjects>
</ProjectReference>
<ProjectReference Include="/home/yoshi/Downloads/hawk-cpm-repro/src/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj.metaproj">
<AdditionalProperties>Configuration=Debug; Platform=Any CPU</AdditionalProperties>
<Platform>AnyCPU</Platform>
<Configuration>Debug</Configuration>
<ToolsVersion>Current</ToolsVersion>
<SkipNonexistentProjects>Build</SkipNonexistentProjects>
</ProjectReference>
</ItemGroup> For
<ItemGroup>
<ProjectReference Include="/home/yoshi/Downloads/hawk-cpm-repro/src/BizHawk.Version/BizHawk.Version.csproj">
<AdditionalProperties>Configuration=Debug; Platform=AnyCPU</AdditionalProperties>
<Platform>AnyCPU</Platform>
<Configuration>Debug</Configuration>
<ToolsVersion>
</ToolsVersion>
<SkipNonexistentProjects>False</SkipNonexistentProjects>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="/home/yoshi/Downloads/hawk-cpm-repro/src/BizHawk.Version/BizHawk.Version.csproj">
<AdditionalProperties>Configuration=Debug; Platform=AnyCPU</AdditionalProperties>
<Platform>AnyCPU</Platform>
<Configuration>Debug</Configuration>
<ToolsVersion>
</ToolsVersion>
<SkipNonexistentProjects>False</SkipNonexistentProjects>
</ProjectReference>
</ItemGroup> However, BizHawk.Common already has a I believe if you remove the project ordering/dependency information from the solution file, things will work. You can also technically remove the project references in the projects themselves since MSBuild is injecting the references on-the-fly when building the solution. But this will break all builds that aren't for the solution file. Thanks for reporting this issue! |
ProjectDependencies
in solution file
NuGet Product Used
dotnet.exe
Product Version
.NET SDK 6.0.400 from AUR
Worked before?
unknown
Impact
It bothers me. A fix would be nice
Repro Steps & Context
In my real codebase, I use
PrivateAssets="all"
to give every project w/ the.props
import certain packages without those packages leaking to dependent projects. Specifically, I addMicrosoft.NETFramework.ReferenceAssemblies
,Nullable
,System.Resources.Extensions
, and various Analyzers.Verbose Logs
output of
dotnet build --verbosity diag
at second, broken commit edit: I've since updated the .NET SDK but still can't build my main project w/ CPMThe text was updated successfully, but these errors were encountered: