Skip to content

Commit 1356cc2

Browse files
committed
Fix issue with localized resources when packing tools
We were missing the %(RecursiveDir) value which caused localized resources to end up as duplicate assets in the package, causing the pack to fail.
1 parent 41df49d commit 1356cc2

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

src/NuGetizer.Tasks/NuGetizer.Inference.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ Copyright (c) .NET Foundation. All rights reserved.
276276
<PackagePathHasFilename Condition="$([MSBuild]::ValueOrDefault('%(PackagePath)', '').EndsWith('%(PackageFile)'))"></PackagePathHasFilename>
277277
</TfmSpecificPackageFile>
278278
<TfmSpecificPackageFile Condition="'%(PackagePathHasFilename)' == 'false'">
279-
<PackagePath>$([MSBuild]::ValueOrDefault('%(PackagePath)', '').TrimEnd('/'))/%(PackageFile)</PackagePath>
279+
<PackagePath>$([MSBuild]::ValueOrDefault('%(PackagePath)', '').TrimEnd('/'))/%(RecursiveDir)%(PackageFile)</PackagePath>
280280
</TfmSpecificPackageFile>
281281
<None Include="@(TfmSpecificPackageFile)" />
282282

src/NuGetizer.Tests/given_a_tool_project.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,27 @@ public void when_pack_as_tool_then_packs_dotnet_tool_runtime_assets()
9090
}));
9191
}
9292

93+
[Fact]
94+
public void when_pack_as_tool_with_localized_resources_then_packs_dotnet_tool_runtime_assets()
95+
{
96+
var result = Builder.BuildProject(@"
97+
<Project Sdk='Microsoft.NET.Sdk'>
98+
<PropertyGroup>
99+
<AssemblyName>MyTool</AssemblyName>
100+
<PackageId>MyTool</PackageId>
101+
<TargetFramework>net8.0</TargetFramework>
102+
<PackFolder>tools</PackFolder>
103+
<PackAsTool>true</PackAsTool>
104+
</PropertyGroup>
105+
<ItemGroup>
106+
<PackageReference Include='Spectre.Console.Cli' Version='0.51.1' />
107+
</ItemGroup>
108+
</Project>",
109+
"Pack", output);
110+
111+
result.AssertSuccess(output);
112+
}
113+
93114
[Fact]
94115
public void when_pack_folder_tool_but_no_pack_as_tool_then_packs_dependencies_normally()
95116
{

0 commit comments

Comments
 (0)