Skip to content

Commit 9a1d3df

Browse files
Modernize VSIX project: Convert to SDK style and add extensibility SDK support
1 parent c9e0751 commit 9a1d3df

3 files changed

Lines changed: 42 additions & 116 deletions

File tree

Vsix/Extension.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
using Microsoft.VisualStudio.Extensibility;
2+
3+
namespace ICSharpCode.CodeConverter.VsExtension;
4+
5+
[VisualStudioContribution]
6+
public class CodeConverterExtension : Extension
7+
{
8+
public override ExtensionConfiguration ExtensionConfiguration => new() {
9+
RequiresInProcessHosting = true,
10+
Metadata = null
11+
};
12+
}

Vsix/VisualStudioInteraction.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ internal static class VisualStudioInteraction
3232
{
3333
private static DTE2 _dte;
3434

35-
/// <remarks>All calls and usages must be from the main thread</remarks>>
36-
internal static DTE2 Dte => _dte ??= Package.GetGlobalService(typeof(DTE)) as DTE2;
35+
/// <remarks>All calls and usages must be from the main thread</remarks>
36+
internal static DTE2 Dte {
37+
get {
38+
ThreadHelper.ThrowIfNotOnUIThread();
39+
return _dte ??= Package.GetGlobalService(typeof(DTE)) as DTE2;
40+
}
41+
}
3742

3843
private static CancellationToken _cancelAllToken;
3944
private static readonly Version LowestSupportedVersion = new(16, 10, 0, 0);

Vsix/Vsix.csproj

Lines changed: 23 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -1,145 +1,54 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<Project ToolsVersion="15.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
1+
<Project Sdk="Microsoft.NET.Sdk">
32
<PropertyGroup>
4-
<MinimumVisualStudioVersion>16.0</MinimumVisualStudioVersion>
5-
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
6-
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7-
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8-
<SchemaVersion>2.0</SchemaVersion>
9-
<RootNamespace>ICSharpCode.CodeConverter.VsExtension</RootNamespace>
10-
<AssemblyName>ICSharpCode.CodeConverter.VsExtension</AssemblyName>
11-
<ProjectGuid>{99498EF8-C9E0-433B-8D7B-EA8E9E66F0C7}</ProjectGuid>
12-
<ProjectTypeGuids>{82B43B9B-A64C-4715-B499-D71E9CA2BD60};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
13-
<OutputType>Library</OutputType>
14-
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
3+
<TargetFramework>net472</TargetFramework>
4+
<ImplicitUsings>disable</ImplicitUsings>
5+
<Nullable>disable</Nullable>
6+
<LangVersion>12</LangVersion>
7+
<UseWPF>true</UseWPF>
8+
9+
<VssdkCompatibleExtension>true</VssdkCompatibleExtension>
1510
<GeneratePkgDefFile>true</GeneratePkgDefFile>
16-
<UseCodebase>true</UseCodebase>
17-
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
1811
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>
1912
<CopyOutputSymbolsToOutputDirectory>true</CopyOutputSymbolsToOutputDirectory>
20-
<VSSDKTargetPlatformRegRootSuffix>Roslyn</VSSDKTargetPlatformRegRootSuffix>
21-
<StartAction>Program</StartAction>
22-
<StartProgram>$(DevEnvDir)devenv.exe</StartProgram>
23-
<StartArguments>/rootsuffix $(VSSDKTargetPlatformRegRootSuffix)</StartArguments>
24-
<SignAssembly>false</SignAssembly>
25-
<DeployExtension Condition="'$(BuildingInsideVisualStudio)' != 'true'">False</DeployExtension>
26-
<RuntimeIdentifiers>win</RuntimeIdentifiers>
27-
<LangVersion>12.0</LangVersion>
28-
</PropertyGroup>
29-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
30-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
31-
<IncludeDebugSymbolsInVSIXContainer>true</IncludeDebugSymbolsInVSIXContainer>
32-
<IncludeDebugSymbolsInLocalVSIXDeployment>true</IncludeDebugSymbolsInLocalVSIXDeployment>
33-
<CopyBuildOutputToOutputDirectory>true</CopyBuildOutputToOutputDirectory>
34-
<DebugSymbols>true</DebugSymbols>
35-
<DebugType>full</DebugType>
36-
<Optimize>false</Optimize>
37-
<OutputPath>bin\Debug\</OutputPath>
38-
<DefineConstants>DEBUG;TRACE</DefineConstants>
39-
<ErrorReport>prompt</ErrorReport>
40-
<WarningLevel>4</WarningLevel>
41-
<CopyVsixExtensionLocation>$(LocalAppData)\Microsoft\VisualStudio\15.0_8bd9890a\Extensions\frc3cnfo.23z</CopyVsixExtensionLocation>
42-
<CopyVsixExtensionFiles Condition="Exists($(CopyVsixExtensionLocation))">True</CopyVsixExtensionFiles>
43-
</PropertyGroup>
44-
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
45-
<DebugType>pdbonly</DebugType>
46-
<Optimize>true</Optimize>
47-
<OutputPath>bin\Release\</OutputPath>
48-
<DefineConstants>TRACE</DefineConstants>
49-
<ErrorReport>prompt</ErrorReport>
50-
<WarningLevel>4</WarningLevel>
5113
</PropertyGroup>
14+
5215
<ItemGroup>
53-
<PackageReference Include="Basic.Reference.Assemblies.NetStandard20">
54-
<Version>1.8.4</Version>
55-
</PackageReference>
56-
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces">
57-
<Version>10.0.2</Version>
58-
</PackageReference>
59-
<!-- Build against VS 16.10 -->
16+
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Sdk" Version="17.14.40608" PrivateAssets="all" />
17+
<PackageReference Include="Microsoft.VisualStudio.Extensibility.Build" Version="17.14.40608" PrivateAssets="all" />
18+
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="17.14.40265" ExcludeAssets="runtime" />
6019
<PackageReference Include="Microsoft.VisualStudio.LanguageServices" Version="4.14.0" />
61-
<PackageReference Include="Microsoft.VisualStudio.SDK" Version="16.10.31321.278" ExcludeAssets="runtime">
62-
<IncludeAssets>compile; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
63-
</PackageReference>
64-
<!-- Avoids needing the VSSDK MSI installed. Version is the VS version used during compilation, not where the VSIX will be installed -->
65-
<PackageReference Include="Microsoft.VSSDK.BuildTools" Version="17.5.4065">
66-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
67-
<PrivateAssets>all</PrivateAssets>
68-
</PackageReference>
20+
<PackageReference Include="Basic.Reference.Assemblies.NetStandard20" Version="1.8.4" />
21+
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="10.0.2" />
22+
</ItemGroup>
23+
24+
<ItemGroup>
25+
<ProjectReference Include="..\CodeConverter\CodeConverter.csproj" />
6926
</ItemGroup>
27+
7028
<ItemGroup>
7129
<VSCTCompile Include="REConverterPackage.vsct">
7230
<ResourceName>Menus.ctmenu</ResourceName>
73-
<SubType>Designer</SubType>
7431
</VSCTCompile>
7532
<Content Include="Images\refactoringessentials-logo90.png">
76-
<IncludeInVSIX>true</IncludeInVSIX>
7733
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
34+
<IncludeInVSIX>true</IncludeInVSIX>
7835
</Content>
7936
<Content Include="Images\refactoringessentials-preview.png">
80-
<IncludeInVSIX>true</IncludeInVSIX>
8137
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
38+
<IncludeInVSIX>true</IncludeInVSIX>
8239
</Content>
8340
<Content Include="license.txt">
8441
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
8542
<IncludeInVSIX>true</IncludeInVSIX>
8643
</Content>
8744
<None Include="source.extension.vsixmanifest" />
88-
</ItemGroup>
89-
<ItemGroup>
90-
<Service Include="{508349B6-6B84-4DF5-91F0-309BEEBAD82D}" />
91-
</ItemGroup>
92-
<ItemGroup>
93-
<Compile Include="AppDomainExtensions.cs" />
94-
<Compile Include="OleMenuCommandWithBlockingStatus.cs" />
95-
<Compile Include="CodeConversion.cs" />
96-
<Compile Include="ConvertCSToVBCommand.cs" />
97-
<Compile Include="ConverterOptionsPage.cs">
98-
<SubType>Component</SubType>
99-
</Compile>
100-
<Compile Include="ConvertVBToCSCommand.cs" />
101-
<Compile Include="OutputWindow.cs" />
102-
<Compile Include="Cancellation.cs" />
103-
<Compile Include="CodeConverterPackage.cs" />
104-
<Compile Include="PasteAsCS.cs" />
105-
<Compile Include="PasteAsVB.cs" />
106-
<Compile Include="ServiceProviderExtensions.cs" />
107-
<Compile Include="SolutionProjectExtensions.cs" />
108-
<Compile Include="TaskExtensions.cs" />
109-
<Compile Include="VisualStudioInteraction.cs" />
110-
<Compile Include="VsDocument.cs" />
111-
</ItemGroup>
112-
<ItemGroup>
113-
<EmbeddedResource Include="VSPackage.resx">
45+
<EmbeddedResource Update="VSPackage.resx">
11446
<MergeWithCTO>true</MergeWithCTO>
11547
<ManifestResourceName>VSPackage</ManifestResourceName>
116-
<SubType>Designer</SubType>
11748
</EmbeddedResource>
11849
</ItemGroup>
119-
<ItemGroup>
120-
<ProjectReference Include="..\CodeConverter\CodeConverter.csproj">
121-
<Project>{7ea075c6-6406-445c-ab77-6c47aff88d58}</Project>
122-
<Name>CodeConverter</Name>
123-
</ProjectReference>
124-
</ItemGroup>
50+
12551
<ItemGroup>
12652
<Reference Include="System.Design" />
127-
<Reference Include="PresentationCore" />
128-
<Reference Include="PresentationFramework" />
12953
</ItemGroup>
130-
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
131-
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" Condition="'$(VSToolsPath)' != ''" />
132-
<PropertyGroup>
133-
<PreBuildEvent>
134-
</PreBuildEvent>
135-
<PostBuildEvent>
136-
</PostBuildEvent>
137-
</PropertyGroup>
138-
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
139-
Other similar extension points exist, see Microsoft.Common.targets.
140-
<Target Name="BeforeBuild">
141-
</Target>
142-
<Target Name="AfterBuild">
143-
</Target>
144-
-->
14554
</Project>

0 commit comments

Comments
 (0)