CreatePkgDef Exception in VS 2019

Viewed 905

I am trying to create a visual studio extension for my Roslyn analyzer in VS 2019. When I set the option Generate .pkgdef File to true I am getting the below exception:

CreatePkgDef : error : ArgumentException: No Visual Studio registration attribute found in this assembly.
The assembly should contain an instance of the attribute 'Microsoft.VisualStudio.Shell.RegistrationAttribute' defined in assembly 'Microsoft.VisualStudio.Shell.Framework' version '16.0.0.0' 
   at Microsoft.VisualStudio.Tools.CreatePkgDef.ProcessAssembly(String fileName, Hive hive, PkgDefContext context, Boolean register, RegistrationMode mode)
   at Microsoft.VisualStudio.Tools.CreatePkgDef.DoCreatePkgDef(InputArguments inputArguments)
   at Microsoft.VisualStudio.Tools.CreatePkgDef.Main(String[] arguments)
1 Answers

In my case, I had one project that was originally tasked with making a VSIX AND contained a lot of classes/views/viewmodels. I wanted to create a separate VSIX installer project and started receiving this 'CreatePkgDef : error : ArgumentException: No Visual Studio registration attribute found in this assembly.The assembly should contain an instance of the attribute 'Microsoft.VisualStudio.Shell.RegistrationAttribute' error.

What worked for me was editing the original project's .csproj file to change true to false in this element:

<GeneratePkgDefFile>false</GeneratePkgDefFile>

If the < GeneratePkgDefFile > element does not already exist, simply add it within the < PropertyGroup > element near the top.

Related