- Roslyn Cookbook
- Manish Vasani
- 318字
- 2021-07-15 17:07:36
Publishing NuGet package and VSIX for an analyzer project
We will show you how to configure, build, and publish a NuGet package and a VSIX package for an analyzer project created in Visual Studio 2017 using the .NET Compiler platform SDK.
Before we start digging into these topics, let's understand the difference between NuGet-based analyzer packages and VSIX-based analyzer packages. NuGet and VSIX are basically two different packaging schemes for the Microsoft development platform to package files such as assemblies, resources, build targets, tools, and so on, into a single installable package.
- NuGet is a more generic packaging scheme. NuGet packages (.nupkg files) can be directly referenced in .NET projects and installed to a specific project or solution using the NuGet package manager in Visual Studio. Analyzer NuGet packages based on the analyzer template project get installed as AnalyzerReferences in the project file, and then get passed onto the compiler command line to be executed during build. Additionally, AnalyzerReferences are resolved at design time by the Visual Studio IDE and executed while code editing to generate live diagnostics.
- A VSIX package is a .vsix file that contains one or more Visual Studio extensions, together with the metadata Visual Studio uses to classify and install the extensions. An analyzer VSIX package can be installed machine-wide or to a specific extension hive, and is enabled for all projects/solutions opened from the Visual Studio hive. Unlike a NuGet package, it cannot be installed specifically to a project/solution and does not travel along with the project sources.
As of Visual Studio 2017, analyzers installed as AnalyzerReferences via NuGet packages execute during both: command line builds and live code editing in Visual Studio. Analyzers installed via Analyzer VSIX packages execute only during live code editing in Visual Studio and not during project build. Hence, only analyzer NuGet packages can be configured to execute in continuous integration (CI) build systems and break the build.
推薦閱讀
- 計(jì)算思維與算法入門
- Delphi程序設(shè)計(jì)基礎(chǔ):教程、實(shí)驗(yàn)、習(xí)題
- C#程序設(shè)計(jì)教程
- iOS編程基礎(chǔ):Swift、Xcode和Cocoa入門指南
- Responsive Web Design by Example
- 單片機(jī)應(yīng)用與調(diào)試項(xiàng)目教程(C語言版)
- Python編程實(shí)戰(zhàn)
- Java編程的邏輯
- 圖數(shù)據(jù)庫實(shí)戰(zhàn)
- Visual FoxPro 6.0程序設(shè)計(jì)
- Java Web應(yīng)用開發(fā)給力起飛
- NGUI for Unity
- Python Digital Forensics Cookbook
- Yii2 By Example
- Mapping with ArcGIS Pro