0

I have built a little C# Code Analyzer with works when used locally as an extension. It is based on the "CodeFix + Analyzer" template from Visual Studio. However when I want deploy it as a NuGet package and try to install that package it fails saying that there is no analyzer folder. This is the error message (german):

Es wird versucht, Informationen zu Abhängigkeiten für das Paket "PersStyleCop.1.0.0-b0000029580" bezüglich des Projekts "ConsoleApplication1" mit dem Ziel ".NETFramework,Version=v4.5.2" zu erfassen.
Es wird versucht, Abhängigkeiten für das Paket "PersStyleCop.1.0.0-b0000029580" mit dem DependencyBehavior "Lowest" aufzulösen.
Aktionen zum Installieren des Pakets "PersStyleCop.1.0.0-b0000029580" werden aufgelöst.
Aktionen zum Installieren des Pakets "PersStyleCop.1.0.0-b0000029580" wurden aufgelöst.
Das Paket "PersStyleCop.1.0.0-b0000029580" wird dem Ordner "C:\Users\JannerG\Documents\Visual Studio 2015\Projects\ConsoleApplication1\packages" hinzugefügt.
Das Paket "PersStyleCop.1.0.0-b0000029580" wurde dem Ordner "C:\Users\JannerG\Documents\Visual Studio 2015\Projects\ConsoleApplication1\packages" hinzugefügt.
Das Paket "PersStyleCop.1.0.0-b0000029580" wurde "packages.config" hinzugefügt.
Die Skriptdatei "C:\Users\JannerG\Documents\Visual Studio 2015\Projects\ConsoleApplication1\packages\PersStyleCop.1.0.0-b0000029580\tools\install.ps1" wird ausgeführt....
Join-Path : Der Pfad "C:\Users\JannerG\Documents\Visual Studio 
2015\Projects\ConsoleApplication1\packages\PersStyleCop.1.0.0-b0000029580\analyzers" kann nicht gefunden werden, da er 
nicht vorhanden ist.In C:\Users\JannerG\Documents\Visual Studio 
2015\Projects\ConsoleApplication1\packages\PersStyleCop.1.0.0-b0000029580\tools\install.ps1:12 Zeichen:19
+ $analyzersPaths = Join-Path (Join-Path (Split-Path -Path $toolsPath -Parent) "an ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (C:\Users\Janner...29580\analyzers:String) [Join-Path], ItemNotFoundExce 
   ption
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.JoinPathCommand

"PersStyleCop 1.0.0-b0000029580" wurde erfolgreich auf "ConsoleApplication1" installiert.
========== Abgeschlossen ==========

There is however a lib\portable45-net45+win8 folder in which the DLL PersStyleCop is which should contain the analyzer.

I tweaked the installation script Install.ps1 so that the lib path is used and that DLL is added as an analyzer reference. However it is not added as an analyzer reference but a normal reference and no code analysis is performed.

The folder structure for the created package is like this:

lib
    portable45-net45+win8
        PersStyleCop.dll
tools
    install.ps1
    uninstall.ps1

So how do I create correct Roslyn NuGet analyzer packages? The deployment is made using Jenkins and Gradle.

Paulo Morgado
  • 14,111
  • 3
  • 31
  • 59
Guillermo
  • 764
  • 6
  • 15
  • Can you show the contents of the .nupkg? You need to have your analyzer dll in the `analyzers` folder -- otherwise you get the result you have where it considers it a normal reference – Jeroen Vannevel Mar 10 '17 at 11:37
  • I updated the question with contenst of the nuget – Guillermo Mar 10 '17 at 12:30
  • I really wonder why no analyzer folder is created. – Guillermo Mar 10 '17 at 18:15
  • Not sure why but you can adapt the file yourself and see if it works like that. – Jeroen Vannevel Mar 10 '17 at 20:41
  • In order to answer this question I will need to know what your nuspec file looks like, If you installed the roslyn SDK from [here](https://marketplace.visualstudio.com/items?itemName=VisualStudioProductTeam.NETCompilerPlatformSDK) then you should have a nupec file with contents like `` which will place the analyzer dll under the analyzers folder in the nuget package and allow things to work. – Jonathon Marolf Mar 10 '17 at 21:34
  • @JeroenVannevel The problem is that i can't adapt it because it's built by a Jenkins server and deployed via Nexus. So when I try to install it I have no chance to change the package manually before installing it over the package manager. – Guillermo Mar 11 '17 at 22:27
  • @JonathonMarolf I have installed the Roselyn SDK (locally). But in this case the NuGet package is built via Jenkins, how is the behavior there, do I also have to install the Rolsyn SDK somehow on Jenkins? The `` tag is present because I used the Visual Studio template to create the analyzer. I only changed the analyser itself but not the nuspec or other build relevant files. – Guillermo Mar 11 '17 at 22:29
  • You should not need to tell jenkins to do anything regarding producing a nuget package, just building the project should produce a nuget package. How have you configured Jenkins? – Jonathon Marolf Mar 12 '17 at 00:19

0 Answers0