Is it possible to automatically run a script (batch file, powershell, etc.) during or after a VSIX install? I'm trying to work around this problem, which requires writing a value to the registry outside of the $RootKey$. I'm hoping that I can simply call a batch or PowerShell script to perform the required registry write for me. I've already got the scripts written, I'm just not sure how or if I can call them during the VSIX install.

I do have a .pkgdef file already in my VSIX, so I was hoping that I could just do something like "Start [PathToBatchScript]" at the bottom of that file to run my batch script, but it doesn't seem to be working.

I've read in a few places that this was not possible with the old 2010 VSIX model, but am hoping that it changed with the new 2012 model.

We are using Visual Studio 2012. Any suggestions are appreciated. Thanks.

有帮助吗?

解决方案

Unfortunately there's no way to run scripts after install/uninstall a VSIX:

Look at this MSDN if you search for "Configuration during install" you will read it's not supported by VSIX but only by MSI. I don't think in Vs2012 this has changed. Howver I'm running into the same problem, I opted for this solution:

public sealed class YourPackage : Package
{
    protected override void Initialize()
    {
        base.Initialize();

        var dte = (DTE2)GetService(typeof(SDTE));
        _dteEvents = dte.Events.DTEEvents;
        _dteEvents.OnStartupComplete += OnStartupComplete;
        _dteEvents.OnBeginShutdown += OnBeginShutdown;
    }

    private void OnBeginShutdown()
    {
        _dteEvents.OnBeginShutdown -= OnBeginShutdown;
        _dteEvents = null;
        //Run your script
    }

    private void OnStartupComplete()
    {
        _dteEvents.OnStartupComplete -= OnStartupComplete;
        _dteEvents = null;
        //Run your script
    }

}

it won't be as neat as a powershell script that run once, but it's a solution.

Hope it helps.

其他提示

I might be late to the party, but you might want to look at this. https://github.com/madskristensen/ProtocolHandlerSample

In this example they add a protocol handler to their extention, which is going to be in the Windows registry. I think you can a lot more with it than just adding a protocol handler.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top