Suppress dependencies when packing
Some packing scenarios, especially those involving tools, require ignoring all dependencies (PackageReference as well as framework references) from the resulting package dependencies.
I learned of a property supported by dotnet pack for this:
1
<PropertyGroup>
2
<SuppressDependenciesWhenPacking>true</SuppressDependenciesWhenPacking>
3
</PropertyGroup>
Copied!
NuGetizer has more flexibility in this regard, providing both a $(PackFrameworkReferences) property as well as granular control over referenced packages via the Pack metadata on each PackageReference:
1
<PropertyGroup>
2
<!-- Opt out of all framework references/dependencies -->
3
<PackFrameworkReferences>false</PackFrameworkReferences>
4
</PropertyGroup>
5
6
<ItemDefinitionGroup>
7
<PackageReference>
8
<!-- Unless specified otherwise, opt-out of all dependencies -->
9
<Pack>false</Pack>
10
</PackageReference>
11
</ItemDefinitionGroup>
12
13
<ItemGroup>
14
<!-- Example of explicitly opting in for a particular one -->
15
<PackageReference Include="Foo" Pack="true" />
16
<PackageReference Include="Bar" /> <!-- Will not be packed -->
17
</ItemGrop>
Copied!
But in order to simplify this scenario further, both the compatibility SuppressDependenciesWhenPacking property as well as a new PackDependencies property is supported in nugetizer to achieve the same.
Last modified 1mo ago
Copy link