Visual Studio 2022:无法从“带有代码修复的分析器(.NET 标准)”项目模板安装 VSIX 扩展

问题描述 投票:0回答:1

我目前正在尝试为 Visual Studio 2022 创建新的代码分析规则,因此我遵循了此教程

当您按照本教程进行操作时,您必须创建一个带有代码修复(.NET Standard)项目的新分析器,该项目实际上会在您的新解决方案中创建 5 个项目(规则定义/代码修复/包/测试/VSIX)。

我成功创建了代码分析规则,并且可以在开始调试 VSIX 项目时对其进行测试。它打开 Visual Studio 的第二个实例,我可以编写一些代码并查看我的规则是否适用...

但是我无法通过 VSIX 扩展文件将其安装在我自己的 Visual Studio 上。当我尝试安装它时出现以下错误:

04/01/2024 15:05:56 - Microsoft VSIX Installer
04/01/2024 15:05:56 - -------------------------------------------
04/01/2024 15:05:56 - vsixinstaller.exe version:
04/01/2024 15:05:56 - 17.8.2365+1ea9c98024
04/01/2024 15:05:56 - -------------------------------------------
04/01/2024 15:05:56 - Command line parameters:
04/01/2024 15:05:56 - C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service\VSIXInstaller.exe,D:\ProjectNET\Rules\SDNARules\NETStandardByRefRules.Vsix\bin\Debug\net481\NETStandardByRefRules.Vsix.vsix
04/01/2024 15:05:56 - -------------------------------------------
04/01/2024 15:05:56 - Microsoft VSIX Installer
04/01/2024 15:05:56 - -------------------------------------------
04/01/2024 15:05:56 - Initializing Install...
04/01/2024 15:05:56 - Searching for applicable products...
04/01/2024 15:05:57 - Found installed product - Visual Studio Enterprise 2022
04/01/2024 15:05:57 - Found installed product - Global Location
04/01/2024 15:05:57 - Extension Details...
04/01/2024 15:05:57 -   Identifier         : SDNACodeAnalysisRules.Silicon DNA 1994..47352a77-3f81-4d95-a389-a64702e17c53
04/01/2024 15:05:57 -   Name               : SDNARules
04/01/2024 15:05:57 -   Author             : ALP
04/01/2024 15:05:57 -   Version            : 1.0
04/01/2024 15:05:57 -   Description        : This is a sample diagnostic extension for the .NET Compiler Platform ("Roslyn").
04/01/2024 15:05:57 -   Locale             : en-US
04/01/2024 15:05:57 -   MoreInfoURL        : 
04/01/2024 15:05:57 -   InstalledByMSI     : False
04/01/2024 15:05:57 -   SupportedFrameworkVersionRange : [4.5,)
04/01/2024 15:05:57 -   SignatureState     : Unsigned
04/01/2024 15:05:57 -   Supported Products : 
04/01/2024 15:05:57 -       Microsoft.VisualStudio.Community
04/01/2024 15:05:57 -           Version : [15.0,)
04/01/2024 15:05:57 -           ProductArchitecture : x86
04/01/2024 15:05:57 -   References         : 
04/01/2024 15:05:57 -   Prerequisites      : 
04/01/2024 15:05:57 -       -------------------------------------------------------
04/01/2024 15:05:57 -       Identifier   : MyCustomPrerequisite
04/01/2024 15:05:57 -       Name         : My Custom Prerequisite
04/01/2024 15:05:57 -       Version      : [1.0,)
04/01/2024 15:05:57 - Signature Details...
04/01/2024 15:05:57 -   Extension is not signed.
04/01/2024 15:05:57 - VSIXInstaller.NoApplicableSKUsException: This extension is not installable on any currently installed products.
   at VSIXInstaller.ExtensionService.GetInstallableDataImpl(String vsixPath, String extensionPackParentName, Boolean isRepairSupported, IStateData stateData, IEnumerable`1& skuData)
   at VSIXInstaller.ExtensionService.GetInstallableData(String vsixPath, String extensionPackParentName, Boolean isRepairSupported, IStateData stateData, IEnumerable`1& skuData)
   at VSIXInstaller.ExtensionPackService.IsExtensionPack(IStateData stateData, Boolean isRepairSupported)
   at VSIXInstaller.ExtensionPackService.ExpandExtensionPackToInstall(IStateData stateData, Boolean isRepairSupported)
   at VSIXInstaller.App.Initialize(Boolean isRepairSupported)
   at VSIXInstaller.App.Initialize()
   at System.Threading.Tasks.Task`1.InnerInvoke()
   at System.Threading.Tasks.Task.Execute()

这是我在 VSIX 项目中的 source.extension.vsixmanifest 文件:

<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
  <Metadata>
    <Identity Id="SDNACodeAnalysisRules.Silicon DNA 1994..47352a77-3f81-4d95-a389-a64702e17c53" Version="1.0" Language="en-US" Publisher="ALP"/>
    <DisplayName>SDNARules</DisplayName>
    <Description xml:space="preserve">This is a sample diagnostic extension for the .NET Compiler Platform ("Roslyn").</Description>
  </Metadata>
  <Installation>
    <InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[15.0,)" />
  </Installation>
  <Dependencies>
    <Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
  </Dependencies>
  <Assets>
    <Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="SDNARules" Path="|SDNARules|"/>
    <Asset Type="Microsoft.VisualStudio.Analyzer" d:Source="Project" d:ProjectName="SDNARules" Path="|SDNARules|"/>
    <Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="SDNARules.CodeFixes" Path="|SDNARules.CodeFixes|"/>
    <Asset Type="Microsoft.VisualStudio.Analyzer" d:Source="Project" d:ProjectName="SDNARules.CodeFixes" Path="|SDNARules.CodeFixes|"/>
  </Assets>
  <Prerequisites>
      <Prerequisite Id="MyCustomPrerequisite" Version="[1.0,)" DisplayName="My Custom Prerequisite" />
  </Prerequisites>
</PackageManifest>

这是一张图片:

enter image description here

如果您愿意,我可以提供我的代码,但我用一个新创建的项目进行了测试,这是相同的结果,所以我不认为我的规则是问题所在。

提前致谢。

我尝试以框架 4.7.2 和 4.8 为目标,将项目的体系结构设置为 x64,通过 .nupkg 文件安装 Nuget 包,我在 VSIXManifest 文件中创建了自己的先决条件,等等

project rules vsix roslyn-code-analysis
1个回答
0
投票

您想将其安装到哪个版本? packagevmanifest 将社区作为目标 - 这可能是问题所在吗?

© www.soinside.com 2019 - 2024. All rights reserved.