Quantcast
Channel: Active questions tagged nuget-package - Stack Overflow
Viewing all articles
Browse latest Browse all 3067

Control nuspec include/exclude with MSBuild pack target

$
0
0

I have the following project file:

<Project Sdk="Microsoft.NET.Sdk"><PropertyGroup><TargetFramework>net6.0</TargetFramework></PropertyGroup><ItemGroup><PackageReference Include="Newtonsoft.Json" Version="13.0.1" /></ItemGroup></Project>

If I run the msbuild /t:pack on this project, the resultant nuspec will have the follwoing dependency group:

<group targetFramework="net6.0"><dependency id="Newtonsoft.Json" version="13.0.1" exclude="Build,Analyzers" /></group>

I need "exclude" to not have "Build". I tried changing Netwonsoft.Json reference to

<PackageReference Include="Newtonsoft.Json" Version="13.0.1" IncludeAssets="build" />

but it resulted in:

<group targetFramework="net6.0"><dependency id="Newtonsoft.Json" version="13.0.1" exclude="Runtime,Compile,Build,Native,Analyzers,BuildTransitive" /></group>

Not even close to what I expected. How do I achieve the desired result, and, more importantly, how do PackageReference IncludeAssets/ExcludeAssets/PrivateAssets get mapped to nuspec include/exclude?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>