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

Is it impossible to have NuGet-dependencies at .nuspec of a Roslyn analyzer package?

$
0
0

Scenario 1 (Good):

  1. Create new VisualStudio solution by Class-Library (.Net Standard 2.0) template.
  2. Install any nuGet-package to it (e.g. Newtonsoft.Json)
  3. Right click on project, Properties -> Package -> Mark "Generate NuGet package on build"
  4. Build solution
  5. 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:

  1. 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)
  2. Install same nuGet-package to it (e.g. Newtonsoft.Json)
  3. Right click on project .Package, Properties -> Package -> You'll see, "Generate NuGet package on build" is already marked.
  4. Build solution
  5. Check produced .nupckg file (it is at .Package project bin/Debug folder) - you'll find, .nuspecDOES 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?


Viewing all articles
Browse latest Browse all 3067

Trending Articles



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