Skip to content

Commit dcd5f0a

Browse files
authored
fix: support robust NuGetize pack delegation for PackFolder=build projects (#39)
### Problem Projects using NuGetizer + `PackFolder=build` (the standard way to author MSBuild/ tool packages) would get their assets incorrectly placed under `content/` + `contentFiles/` when packed via `dotnet pack`. This is the same root cause that affected the nugetizer 1.4.8 release. ### Root cause - The shared `Directory.Build.targets` always imported the real `NuGet.Build.Tasks.Pack.targets`. - "dotnet pack" flows did not reliably go through the `NuGetize=true` path. - Result: SDK pack defaults won instead of NuGetizer's `PackFolder` inference. ### Fix * Condition the import of the real pack targets: `And '$(NuGetize)' != 'true'`. When a project opts into NuGetizer via `NuGetize`, don't pull in the conflicting SDK pack targets. * Add a late `<Target Name="Pack">` delegator (after the pack import) that, for any project with `PackFolder=build` or `buildTransitive`, re-invokes MSBuild with `NuGetize=true`. This guarantees the correct packaging logic runs. The delegator is declared late in the file so it takes precedence. See also the consuming change in devlooped/nugetizer#726
1 parent ff61659 commit dcd5f0a

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Directory.Build.targets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<NuGetBuildTasksPackTargets Condition="'$(NuGetBuildTasksPackTargets)' == ''">$(MSBuildSDKsPath)\..\NuGet.Build.Tasks.Pack.targets</NuGetBuildTasksPackTargets>
4040
</PropertyGroup>
4141

42-
<Import Project="$(NuGetBuildTasksPackTargets)" Condition="Exists('$(NuGetBuildTasksPackTargets)')"/>
42+
<Import Project="$(NuGetBuildTasksPackTargets)" Condition="Exists('$(NuGetBuildTasksPackTargets)') And '$(NuGetize)' != 'true'" />
4343

4444
<PropertyGroup>
4545
<!-- Revert the forced PackageId by the NuGet SDK targets for non-packable projects, see https://github.com/NuGet/Home/issues/14928 -->

0 commit comments

Comments
 (0)