Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/OpenSilver.VSIX/OpenSilver.VSIX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
<OutputPath>bin\OpenSilver\$(Configuration)\</OutputPath>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<UseCodebase>true</UseCodebase>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down Expand Up @@ -35,17 +36,18 @@
<RootNamespace>OpenSilver.VSIX</RootNamespace>
<AssemblyName>OpenSilver</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<GeneratePkgDefFile>false</GeneratePkgDefFile>
<IncludeAssemblyInVSIXContainer>false</IncludeAssemblyInVSIXContainer>
<GeneratePkgDefFile>true</GeneratePkgDefFile>
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
<IncludeDebugSymbolsInVSIXContainer>false</IncludeDebugSymbolsInVSIXContainer>
<IncludeDebugSymbolsInLocalVSIXDeployment>false</IncludeDebugSymbolsInLocalVSIXDeployment>
<CopyBuildOutputToOutputDirectory>false</CopyBuildOutputToOutputDirectory>
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>
<CopyOutputSymbolsToOutputDirectory>false</CopyOutputSymbolsToOutputDirectory>
<StartAction>Program</StartAction>
<StartProgram Condition="'$(DevEnvDir)' != ''">$(DevEnvDir)devenv.exe</StartProgram>
<StartArguments>/rootsuffix Exp</StartArguments>
</PropertyGroup>
<ItemGroup>
<Compile Include="OpenSilverPackage.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
Expand Down Expand Up @@ -234,6 +236,9 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="VSSDK.ExtensionManager">
<Version>11.0.0</Version>
</PackageReference>
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Expand Down
72 changes: 72 additions & 0 deletions src/OpenSilver.VSIX/OpenSilverPackage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Threading;
using Microsoft.VisualStudio.ExtensionManager;
using System;
using System.Threading;
using System.Threading.Tasks;
using System.Diagnostics;

namespace OpenSilver.VSIX
{
[PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)]
[InstalledProductRegistration("OpenSilver SDK", "OpenSilver SDK for Visual Studio", "3.0")]
[ProvideAutoLoad(UIContextGuids80.NoSolution, PackageAutoLoadFlags.BackgroundLoad)]
public sealed class OpenSilverPackage : AsyncPackage
{
private const string OldExtensionId = "OpenSilver.64201874-6ead-4828-b5af-31a76285b73d";

protected override async Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress)
{
await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

DetectOldExtension();
}

private void DetectOldExtension()
{
ThreadHelper.ThrowIfNotOnUIThread();

try
{
IVsExtensionManager extensionManager = (IVsExtensionManager)GetService(typeof(SVsExtensionManager));
if (extensionManager != null)
{
foreach (var extension in extensionManager.GetInstalledExtensions())
{
if (string.Equals(extension.Header.Identifier, OldExtensionId, StringComparison.OrdinalIgnoreCase))
{
int result = VsShellUtilities.ShowMessageBox(
this,
"An older version of the OpenSilver extension is installed. Please uninstall the old version to avoid conflicts.\n\n" +
"Would you like to open a page with detailed instructions on how to proceed?",
"Extension Conflict Detected",
OLEMSGICON.OLEMSGICON_WARNING,
OLEMSGBUTTON.OLEMSGBUTTON_YESNO,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);

if (result == (int)Microsoft.VisualStudio.VSConstants.MessageBoxResult.IDYES)
{
Process.Start(new ProcessStartInfo("https://opensilver.net/uninstall-old-extension")
{
UseShellExecute = true
});
}
break;
}
}
}
}
catch (Exception ex)
{
VsShellUtilities.ShowMessageBox(
this,
"An error occurred while checking for old extensions: " + ex.Message,
"Error",
OLEMSGICON.OLEMSGICON_CRITICAL,
OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST);
}
}
}
}
5 changes: 3 additions & 2 deletions src/OpenSilver.VSIX/source.extension.vsixmanifest
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="OpenSilver.64201874-6ead-4828-b5af-31a76285b73d" Version="3.1.0.6" Language="en-US" Publisher="Userware" />
<DisplayName>OpenSilver</DisplayName>
<Identity Id="OpenSilverSDK.f8d7e167-8c6f-45d1-823a-5724c26edac8" Version="3.1.0.10" Language="en-US" Publisher="Userware" />
<DisplayName>OpenSilver SDK</DisplayName>
<Description xml:space="preserve">Project templates and XAML Designer for creating OpenSilver applications. OpenSilver is an open-source reimplementation of Silverlight that runs on current browsers via WebAssembly.</Description>
<Icon>Logo_32x32.png</Icon>
<PreviewImage>Logo_200x200.png</PreviewImage>
Expand Down Expand Up @@ -65,5 +65,6 @@
<Asset Type="Microsoft.VisualStudio.Assembly" d:Source="File" Path="ItemTemplates\Assemblies\OpenRiaServices.VisualStudio.DomainServices.Tools.14.0.dll" AssemblyName="OpenRiaServices.VisualStudio.DomainServices.Tools.14.0, Version=4.0.0.0, Culture=neutral, PublicKeyToken=2e0b7ccb1ae5b4c8" />
<Asset Type="Microsoft.VisualStudio.ItemTemplate" d:Source="File" Path="ItemTemplates" d:TargetPath="ItemTemplates\VisualBasic\Web\1033\DomainServiceClass.zip" />
<Asset Type="Microsoft.VisualStudio.ProjectTemplate" d:Source="Project" d:ProjectName="OpenSilverMauiHybridTemplate" d:TargetPath="|OpenSilverMauiHybridTemplate;TemplateProjectOutputGroup|" Path="ProjectTemplates" d:VsixSubPath="ProjectTemplates" />
<Asset Type="Microsoft.VisualStudio.VsPackage" d:Source="Project" d:ProjectName="%CurrentProject%" Path="|%CurrentProject%;PkgdefProjectOutputGroup|" />
</Assets>
</PackageManifest>