Background:
I am creating NuGet packages of projects for my company, these NuGet packages will then be installed into other internal projects. Currently, I am doing it with the built-in functionality of .NET Standard/Core projects. This works as desired, however, all our projects have a "wrapper NuGet package" installed for some code analysis (StyleCop NuGet package + company-specific ruleset files and Json files).
If I want to install a NuGet package (that I created) into another project, it always adds the dependency on our style analyzer NuGet package.
This is what it looks like installed in a project:
Question:
Is there a way that I can remove the dependency on a specific NuGet package upon NuGet package creation? i.e Is there a way that I can do something in the line of (.csproj file):
<ItemGroup>
<PackageReference Condition="'$(Configuration)'=='Debug'" Include="CompanyStyleAnalyzer" Version="1.1.6" />
</ItemGroup>
but instead of specifying the actual version I ALWAYS want to remove the dependency no matter what the version is when I build the project in the "Release" configuration, or even better, every time the Dotnet pack is run, something specifying to not include the dependency in the final package.
Is this a "frowned-upon" way of removing dependencies in the project?
The previous way I generated NuGet packages (in .Net Framework), was to use the NuGet CLI - pack command, and then extract the file and edit the .Nuspec file to remove the dependency manually. I do not want to have to edit the Nuspec file and repack the package.
Can anyone specify what I can do in this regards, please?
PrivateAssets=all
? docs.microsoft.com/en-us/nuget/consume-packages/… – Ian Kemp