Skip to content

Commit 6fd37a2

Browse files
committed
Switching visualizers installer to use .NET Standard project / Adding WIX installer project
1 parent f8ac6d4 commit 6fd37a2

File tree

13 files changed

+840
-20
lines changed

13 files changed

+840
-20
lines changed

ReadableExpressions.Visualizers.Core/ReadableExpressions.Visualizers.Core.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@
5151
<Folder Include="Properties\" />
5252
</ItemGroup>
5353
<ItemGroup>
54-
<ProjectReference Include="..\ReadableExpressions.Net40\ReadableExpressions.Net40.csproj">
55-
<Project>{7a33da5b-5dee-42cb-a354-a77766b635ba}</Project>
56-
<Name>ReadableExpressions.Net40</Name>
54+
<ProjectReference Include="..\ReadableExpressions\ReadableExpressions.csproj">
55+
<Project>{147ddcce-cdd3-4dd0-8ba3-d3f2f239e161}</Project>
56+
<Name>ReadableExpressions</Name>
5757
</ProjectReference>
5858
</ItemGroup>
5959
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<configuration>
3+
<startup useLegacyV2RuntimeActivationPolicy="true">
4+
5+
<!--
6+
Use supportedRuntime tags to explicitly specify the version(s) of the .NET Framework runtime that
7+
the custom action should run on. If no versions are specified, the chosen version of the runtime
8+
will be the "best" match to what Microsoft.Deployment.WindowsInstaller.dll was built against.
9+
10+
WARNING: leaving the version unspecified is dangerous as it introduces a risk of compatibility
11+
problems with future versions of the .NET Framework runtime. It is highly recommended that you specify
12+
only the version(s) of the .NET Framework runtime that you have tested against.
13+
14+
Note for .NET Framework v3.0 and v3.5, the runtime version is still v2.0.
15+
16+
In order to enable .NET Framework version 2.0 runtime activation policy, which is to load all assemblies
17+
by using the latest supported runtime, @useLegacyV2RuntimeActivationPolicy="true".
18+
19+
For more information, see http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx
20+
-->
21+
22+
<supportedRuntime version="v4.0" />
23+
<supportedRuntime version="v2.0.50727"/>
24+
25+
</startup>
26+
27+
<!--
28+
Add additional configuration settings here. For more information on application config files,
29+
see http://msdn.microsoft.com/en-us/library/kza1yk3a.aspx
30+
-->
31+
32+
</configuration>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
namespace AgileObjects.ReadableExpressions.Visualizers.Installer.Custom
2+
{
3+
using System.Collections.Generic;
4+
using System.IO;
5+
using System.Linq;
6+
7+
internal static class EmbeddedResourceExtensions
8+
{
9+
public static IEnumerable<string> WithExtension(this string[] resourceNames, string extension)
10+
{
11+
return resourceNames
12+
.Where(resourceName => Path.GetExtension(resourceName)?.ToLowerInvariant() == "." + extension);
13+
}
14+
}
15+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
using System.Reflection;
2+
using System.Runtime.InteropServices;
3+
4+
[assembly: AssemblyDescription("")]
5+
[assembly: AssemblyConfiguration("")]
6+
[assembly: AssemblyTrademark("")]
7+
[assembly: AssemblyCulture("")]
8+
[assembly: ComVisible(false)]
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" InitialTargets="EnsureWixToolsetInstalled" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{F0FCABC6-52C4-4670-AD28-7DC20B44B13D}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>AgileObjects.ReadableExpressions.Visualizers.Installer.Custom</RootNamespace>
12+
<AssemblyName>ReadableExpressions.Visualizers.Installer.Custom</AssemblyName>
13+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<TargetFrameworkProfile />
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\Debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
27+
<DebugType>pdbonly</DebugType>
28+
<Optimize>true</Optimize>
29+
<OutputPath>bin\Release\</OutputPath>
30+
<DefineConstants>TRACE</DefineConstants>
31+
<ErrorReport>prompt</ErrorReport>
32+
<WarningLevel>4</WarningLevel>
33+
</PropertyGroup>
34+
<ItemGroup>
35+
<Reference Include="System" />
36+
<Reference Include="System.Core" />
37+
<Reference Include="System.Xml.Linq" />
38+
<Reference Include="Microsoft.CSharp" />
39+
<Reference Include="System.Xml" />
40+
<Reference Include="Microsoft.Deployment.WindowsInstaller">
41+
<Private>True</Private>
42+
</Reference>
43+
</ItemGroup>
44+
<ItemGroup>
45+
<Compile Include="..\ReadableExpressions.Visualizers.Core\CommonVisualizerAssemblyInfo.cs">
46+
<Link>CommonVisualizerAssemblyInfo.cs</Link>
47+
</Compile>
48+
<Compile Include="..\VersionInfo.cs">
49+
<Link>VersionInfo.cs</Link>
50+
</Compile>
51+
<Compile Include="RegistryData.cs" />
52+
<Compile Include="VisualizerInstallationActions.cs" />
53+
<Compile Include="EmbeddedResourceExtensions.cs" />
54+
<Compile Include="Properties\AssemblyInfo.cs" />
55+
<Compile Include="Visualizer.cs" />
56+
<Compile Include="VsPost2017Data.cs" />
57+
<EmbeddedResource Include="extension.vsixmanifest" />
58+
<EmbeddedResource Include="..\AgileObjects.ReadableExpressions.Visualizers.Vs10.dll">
59+
<Link>AgileObjects.ReadableExpressions.Visualizers.Vs10.dll</Link>
60+
</EmbeddedResource>
61+
<EmbeddedResource Include="..\AgileObjects.ReadableExpressions.Visualizers.Vs11.dll">
62+
<Link>AgileObjects.ReadableExpressions.Visualizers.Vs11.dll</Link>
63+
</EmbeddedResource>
64+
<EmbeddedResource Include="..\AgileObjects.ReadableExpressions.Visualizers.Vs12.dll">
65+
<Link>AgileObjects.ReadableExpressions.Visualizers.Vs12.dll</Link>
66+
</EmbeddedResource>
67+
<EmbeddedResource Include="..\AgileObjects.ReadableExpressions.Visualizers.Vs14.dll">
68+
<Link>AgileObjects.ReadableExpressions.Visualizers.Vs14.dll</Link>
69+
</EmbeddedResource>
70+
<EmbeddedResource Include="..\AgileObjects.ReadableExpressions.Visualizers.Vs15.dll">
71+
<Link>AgileObjects.ReadableExpressions.Visualizers.Vs15.dll</Link>
72+
</EmbeddedResource>
73+
<Content Include="CustomAction.config" />
74+
</ItemGroup>
75+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
76+
<Import Project="$(WixCATargetsPath)" Condition=" '$(WixCATargetsPath)' != '' " />
77+
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.CA.targets" Condition=" '$(WixCATargetsPath)' == '' AND Exists('$(MSBuildExtensionsPath32)\Microsoft\WiX\v3.x\Wix.CA.targets') " />
78+
<Target Name="EnsureWixToolsetInstalled" Condition=" '$(WixCATargetsImported)' != 'true' ">
79+
<Error Text="The WiX Toolset v3 build tools must be installed to build this project. To download the WiX Toolset, see http://wixtoolset.org/releases/" />
80+
</Target>
81+
</Project>
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
namespace AgileObjects.ReadableExpressions.Visualizers.Installer.Custom
2+
{
3+
using System;
4+
using System.Linq;
5+
using Microsoft.Win32;
6+
7+
internal class RegistryData : IDisposable
8+
{
9+
public RegistryData()
10+
{
11+
const string REGISTRY_KEY = @"SOFTWARE\Microsoft";
12+
13+
MsMachineKey = Registry.LocalMachine.OpenSubKey(REGISTRY_KEY);
14+
15+
if (MsMachineKey == null)
16+
{
17+
NoVisualStudio = true;
18+
return;
19+
}
20+
21+
var vsKeyNames = MsMachineKey
22+
.GetSubKeyNames()
23+
.Where(sk => sk.StartsWith("VisualStudio", StringComparison.Ordinal))
24+
.ToArray();
25+
26+
if (vsKeyNames.Length == 0)
27+
{
28+
NoVisualStudio = true;
29+
return;
30+
}
31+
32+
VsPre2017MachineKey = MsMachineKey.OpenSubKey("VisualStudio");
33+
VsPre2017KeyNames = VsPre2017MachineKey?.GetSubKeyNames() ?? new string[0];
34+
35+
VsPost2015Data = vsKeyNames
36+
.Where(kn => kn.StartsWith("VisualStudio_"))
37+
.Select(kn => new VsPost2017Data(MsMachineKey.OpenSubKey(kn)))
38+
.ToArray();
39+
}
40+
41+
public RegistryKey MsMachineKey { get; }
42+
43+
public RegistryKey VsPre2017MachineKey { get; }
44+
45+
public string[] VsPre2017KeyNames { get; }
46+
47+
public VsPost2017Data[] VsPost2015Data { get; }
48+
49+
public bool NoVisualStudio { get; }
50+
51+
public void Dispose()
52+
{
53+
MsMachineKey?.Dispose();
54+
VsPre2017MachineKey?.Dispose();
55+
56+
foreach (var vsPost2015DataItem in VsPost2015Data)
57+
{
58+
vsPost2015DataItem.Dispose();
59+
}
60+
}
61+
}
62+
}
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
namespace AgileObjects.ReadableExpressions.Visualizers.Installer.Custom
2+
{
3+
using System;
4+
using Microsoft.Win32;
5+
6+
internal class Visualizer : IDisposable
7+
{
8+
public int VsVersionNumber { get; set; }
9+
10+
public string VsFullVersionNumber => VsVersionNumber + ".0";
11+
12+
public string ResourceName { get; set; }
13+
14+
public RegistryKey RegistryKey { get; set; }
15+
16+
public string VsInstallDirectory { get; set; }
17+
18+
public string InstallPath { get; set; }
19+
20+
public string VsixManifestPath { get; set; }
21+
22+
public string VsExePath { get; set; }
23+
24+
public string VsSetupArgument { get; set; }
25+
26+
public Visualizer With(RegistryKey registryKey, string vsInstallPath)
27+
{
28+
return new Visualizer
29+
{
30+
VsVersionNumber = VsVersionNumber,
31+
ResourceName = ResourceName,
32+
RegistryKey = registryKey,
33+
VsInstallDirectory = vsInstallPath
34+
};
35+
}
36+
37+
public void Dispose()
38+
{
39+
RegistryKey?.Dispose();
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)