Question

I'm trying to figure out how to get a single-file generator installed on VS2010. Previously I got it sort-of working on VS2013 after many hours of head-banging; in both cases the primary difficulty is setting up the registry entries. Apparently VSIX files don't allow registry settings:

You can use the VSIX format to package project and item templates, Visual Studio Integration Packages, Managed Extensibility Framework (MEF) components, toolbox controls, assemblies, and custom types. The VSIX format uses strictly file-based deployment and does not support writing to the Global Assembly Cache (GAC), or to the system registry. VSIX is the preferred deployment method for the extension types that it supports.

My VS2013 solution involves the CodeGeneratorRegistrationAttribute and ComVisible(true) on the assembly, but after install, the extension doesn't work until the user runs devenv.exe /setup in Administrator mode. In VS2010, CodeGeneratorRegistrationAttribute does not exist in any of the SDK DLLs and simply adding the source code of CodeGeneratorRegistrationAttribute.cs to the project (as the Single File Generator sample does) doesn't seem to work (and I don't understand why the sample seems to expect it to work; .NET doesn't use structural typing, after all, so how could this attribute possibly have any effect?)

If a VSIX cannot add registry settings directly, I think a reasonable substitute is to include some code that automatically runs on VS startup. That code could find out the path of the registry hive of the running VS version and add the necessary registry settings at that time. So I have three questions:

  1. How can I cause a method written by me, inside my extension, to run when VS starts?
  2. How can I get the path of the current VS registry hive?
  3. Is there any other way to add the registry information?
Was it helpful?

Solution

Eventually I gave up on making a VSIX to hold my single-file generator. I made a CodeProject article about what I did instead.

But back when I was still trying to make a VSIX file, this blog post came in handy.

OTHER TIPS

What is wrong with MSI-deployment? You can do anything from there. WiX has option to install VSIX packages pretty simply, just use the embedded element <VSIXPackage>. It also offers you to create new registry keys + you get registry key unistall for free. Note that you can elevate privileges, if needed.

does your vsix have a class that extends Package?

Add code in your Package's Initialize method that runs when your package is initialized.

To get to VS based registry stuff, see Microsoft.VisualStudio.Shell.VSRegistry

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top