Skip to content

Commit b8ec8dd

Browse files
author
Nick Ficano
committed
fix: add Private=false to ProjectReference to fully eliminate NU5050
The previous fix (Pack=false + PrivateAssets=all) was incomplete. Pack=false stops the project-reference mechanism from adding Arcp.dll a second time, but Arcp.dll was *still* being copied into Arcp.Cli's build-output directory (bin/.../net10.0/) because Private defaults to true. The NuGet pack task for PackAsTool=true maps every file in that output directory to tools/net10.0/any/ — colliding with the copy that dotnet publish (run internally by dotnet pack) already places there. Private=false prevents the copy into the build-output dir, so the pack task only ever sees one source for Arcp.dll: the publish output.
1 parent ad408e9 commit b8ec8dd

1 file changed

Lines changed: 29 additions & 7 deletions

File tree

src/Arcp.Cli/Arcp.Cli.fsproj

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,37 @@
1111
<Compile Include="Program.fs" />
1212
</ItemGroup>
1313
<ItemGroup>
14-
<!-- Pack=false + PrivateAssets=all prevents the NuGet pack task from
15-
adding Arcp's bin-output DLLs as *separate* tools/ content items.
16-
The dotnet publish step (which runs inside dotnet pack for tool
17-
projects) already bundles Arcp.dll and its transitive deps into
18-
tools/net10.0/any/, so without these flags the same files appear
19-
twice in the manifest and the pack fails with NU5050. -->
14+
<!-- Three metadata items are required to prevent NU5050 ("pack multiple
15+
files into the same location") when PackAsTool=true references a
16+
sibling library project.
17+
18+
How NU5050 arises without them:
19+
1. dotnet pack for a tool project internally runs dotnet publish,
20+
which places Arcp.dll (and .pdb/.xml) in publish/ — these are
21+
correctly packed into tools/net10.0/any/.
22+
2. Because Private=true (default), Arcp.dll is also copied into
23+
Arcp.Cli's own build-output dir (bin/…/net10.0/). The NuGet
24+
pack task then maps *all* build-output files to tools/net10.0/any/
25+
as well, producing a duplicate entry → NU5050.
26+
3. The project-reference mechanism (separate from build output)
27+
would also add Arcp.dll from Arcp's own bin/ if Pack != false.
28+
29+
What each flag does:
30+
Private=false — do NOT copy Arcp.dll into Arcp.Cli's build-
31+
output dir, so the pack task has nothing to find
32+
there. (Publish still includes it via its own
33+
full-transitive-closure resolution — that is the
34+
one correct copy.)
35+
Pack=false — suppress the project-reference content path
36+
(source 3 above) from adding a second copy from
37+
Arcp's own bin/.
38+
PrivateAssets=all — prevent Arcp's transitive NuGet dependencies
39+
from appearing as <dependency> entries in the
40+
nuspec; the tool bundles everything it needs. -->
2041
<ProjectReference Include="..\Arcp\Arcp.fsproj">
21-
<PrivateAssets>all</PrivateAssets>
42+
<Private>false</Private>
2243
<Pack>false</Pack>
44+
<PrivateAssets>all</PrivateAssets>
2345
</ProjectReference>
2446
</ItemGroup>
2547
<ItemGroup>

0 commit comments

Comments
 (0)