vsixvisual-studio-sdkvsixmanifest

Add registry key during vsix installation


Is there any way to dynamically add a registry key while installing from a vsix?

For example:

Say we have SomeExtension.vsix. It should check for a AnExisting.dll under

C:\Program Files (x86)\Existing\AnExisting.dll
C:\Program Files (x86)\Existing2\AnExisting.dll

Say it finds under Existing folder Then add

[HKEY_CURRENT_USER\Software]
"C:\Program Files (x86)\Existing"=""

I know of pkgdef, but it seems to be taking a constant value i.e. we cannot get it to dynamically change on the machine it is being installed.

Or is it possible to get an environment variable on the machine it is being installed say we set PRODUCT_HOME accordingly for the vsix to add the value to registry?


Solution

  • This is the easiest way we can do this, although I do not know what side effects it can have. The following is a batch file snippet:

    rem generate a pkgdef with the appropriate value
    echo [HKEY_CURRENT_USER\Software] > MyBindingPaths.pkgdef
    echo "%PRODUCT_HOME%"="" >> MyBindingPaths.pkgdef
    
    rem *** Copy to VS extensions folder, this is a known location to look for pkgdef files ***
    copy MyBindingPaths.pkgdef "%DEVENVDIR%Extensions"
    
    echo *** Installing our VSIX ***
    "%DevEnvDir%\vsixinstaller" -q SomeExtension.vsix
    

    Other better suggestions welcome.