I'm currently trying to create a new code analysis rule for Visual Studio 2022 so i followed this tutorial.
When you follow the tutorial, you have to create a new Analyzer with Code Fix (.NET Standard) project that will in fact create 5 projects into your new solution (Rule definition/Code fixes/Package/Testing/VSIX).
I succeeded to create my code analysis rule and i can test it when i start debugging the VSIX project. It opens a second instance of Visual Studio and i can write some code and see if my rules are applied...
However i'm not able to install it on my own Visual Studio through the VSIX extension file. I have the following error when i try to install it :
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()
And here is my source.extension.vsixmanifest file in the VSIX project :
<?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>
Here is an image :
I can provide my code if you want but i tested with a new created project and this is the same result so i don't think that my rule is the problem.
Thanks in advance.
I have tried to target framework 4.7.2 and 4.8, set the architecture of the projects to x64, to install the Nuget package through the .nupkg file, i have created my own prerequisites in the VSIXManifest file, etc
According to your posting of manifest file, you are using Microsoft.VisualStudio.Community as installation target id.
But according to this: https://learn.microsoft.com/en-us/visualstudio/extensibility/vsix-extension-schema-2-0-reference?view=vs-2022#:~:text=default%20value%20%22ProductExtension%22%3A-,Id,-%2D%20This%20attribute%20identifies, that value seems not to be valid.
I would try to change the installation target id to Microsoft.VisualStudio.Pro