Scenario 1 (Good):
- Create new VisualStudio solution by Class-Library (.Net Standard 2.0) template.
- Install any nuGet-package to it (e.g.
Newtonsoft.Json
) - Right click on project, Properties -> Package -> Mark "Generate NuGet package on build"
- Build solution
- Check produced
.nupckg
file (by NuGet package Explorer of just by 7-Zip) - you'll find,.nuspec
contains section:
<dependencies><group targetFramework=".NETStandard2.0"><dependency id="Newtonsoft.Json" version="13.0.1" exclude="Build,Analyzers" /></group></dependencies>
So, if you install this .nupckg
to some project, Newtonsoft.Json
will be installed also. Good!
BUT! lets see Scenaro 2 (I don't understand it):
Lets move the similar way:
- Create new VisualStudio solution BUT by "Analyzer with Codefix" template. (if you examine the
.Package
project, you'll see, it's the same as our 1st example - it's Class-library with target framework .Net Standard 2.0) - Install same nuGet-package to it (e.g.
Newtonsoft.Json
) - Right click on project
.Package
, Properties -> Package -> You'll see, "Generate NuGet package on build" is already marked. - Build solution
- Check produced
.nupckg
file (it is at.Package
project bin/Debug folder) - you'll find,.nuspec
DOES NOT contain section<dependencies>
.So, when you install this.nupckg
to some project,Newtonsoft.Json
will NOT be installed to it.
My questions:
- Why is the behavior different?
- Is it possible to have NuGet-dependencies at
.nuspec
of a Roslyn analyzer package?
PS: I've found a solution, but I don't like it, `cos it depreciating the sense of packages management ('cos we just burn dependency dlls into our package). Is this the best solution?