Sharing analyzers as Visual Studio extensions
Once you’re ready to try an analyzer on more code or share it with your peers, there are a few options available:
- Deploy the analyzer as a NuGet package, as we’ll discuss in the next chapter
- Create a Visual Studio Installer (VSIX) to install the analyzers locally
- Create a new project and add an explicit reference to the analyzers by editing the
.csproj
file and adding anAnalyzer
node, as shown here:
<ItemGroup> <Analyzer Include="..\some\path\Your.Analyzer.dll" /> </ItemGroup>
This last approach is one you might consider if you had a large solution and wanted your analyzer to only apply to other projects in that solution. However, I’ve found this approach to be buggy and require frequent reloads of Visual Studio for changes in the analyzers to take hold, so we’ll use the VSIX approach as we close out this chapter.