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.