I'm trying to make my extension automatically update itself when new versions are pushed to the Visual Studio Gallery. There are a few guides on how one may achieve this, but they are a couple years old and may not apply.
For starters, I'm trying to query the IVsExtensionRepository
as follows:
var _extensionRepository = (IVsExtensionRepository)Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SVsExtensionRepository));
var query = _extensionRepository.CreateQuery<VSGalleryEntry>(false, true)
.OrderByDescending(n => n.Ranking)
.Skip(0)
.Take(25) as IVsExtensionRepositoryQuery<VSGalleryEntry>;
query.ExecuteCompleted += Query_ExecuteCompleted;
query.ExecuteAsync();
At Query_ExecuteCompleted
I'm receiving an exception from the server: "The remote server returned an error: (400) Bad Request."
A stack trace is provided:
Server stack trace: at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeEndService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
The service is hosted at: https://visualstudiogallery.msdn.microsoft.com/services/dev12/extension.svc
Does anyone know how I can create a Visual Studio extension that automatically updates itself from the Visual Studio Gallery? Either through the IVsExtensionRepository
or manually?
Edit: Now in Visual Studio 2015 extensions are downloaded automatically.
So I've completely abandoned querying the
IVsExtensionRepository
. I'm not sure why, but there must be some internal problem with the queries it constructs. I queried the same service using ErikEJ's suggested project, and it worked fine.However, I didn't want to construct the service from the WSDL as it appears SQLCeToolbox has done. Instead I used the
IVsExtensionRepository
, but avoided theCreateQuery()
method.Attached is my approach to updating my VSPackage. You'll need to replace any GUIDs or Package specific names with your package's information.
NOTE There is one Gotcha' in the following code:
Note that
CodeConnectRepositoryEntry
only implementsDownloadUrl
. When updating the VSPackage, this is all one must worry about as it allows us to download the new package. This URL can be found on the VSGallery page for your VSPackage.However: You must trim the URL as follows:
http://visualstudiogallery.msdn.microsoft.com/c0c2ad47-957c-4e07-89fc-20996595b6dd/file/140793/4/CodeConnectAlpha.vsix
to:
http://visualstudiogallery.msdn.microsoft.com/c0c2ad47-957c-4e07-89fc-20996595b6dd/file/140793/
Above, the /4/ represents the fourth upload. By removing it completely, the Visual Studio Gallery will download the latest version.