Skip to content

Commit

Permalink
Additional reorganization of install scripts & supporting classes
Browse files Browse the repository at this point in the history
Update the code to handle all needed parameterization
Create writers, with Inno Setup writer to generate a .iss file for inclusion
  • Loading branch information
bclothier committed Mar 17, 2018
1 parent c956099 commit 2e841e1
Show file tree
Hide file tree
Showing 13 changed files with 624 additions and 219 deletions.
3 changes: 3 additions & 0 deletions Rubberduck.API/Rubberduck.API.csproj
Expand Up @@ -74,5 +74,8 @@
<ItemGroup>
<Folder Include="API\Plugin\" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
11 changes: 11 additions & 0 deletions Rubberduck.API/app.config
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.1.0" newVersion="4.1.1.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
6 changes: 0 additions & 6 deletions Rubberduck.Core/Rubberduck.Core.csproj
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props" Condition="Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
Expand Down Expand Up @@ -256,10 +255,6 @@
<Reference Include="Infralution.Localization.Wpf">
<HintPath>..\libs\Infralution.Localization.Wpf.dll</HintPath>
</Reference>
<Reference Include="LibGit2Sharp, Version=0.24.0.0, Culture=neutral, PublicKeyToken=7cbde695407f0333, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\packages\LibGit2Sharp.0.24.0\lib\net40\LibGit2Sharp.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Expression.Interactions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\System.Windows.Interactivity.WPF.2.0.20525\lib\net40\Microsoft.Expression.Interactions.dll</HintPath>
</Reference>
Expand Down Expand Up @@ -1404,7 +1399,6 @@
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
<Error Condition="!Exists('..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\LibGit2Sharp.NativeBinaries.1.0.185\build\LibGit2Sharp.NativeBinaries.props'))" />
</Target>
<PropertyGroup>
<PostBuildEvent>
Expand Down
255 changes: 85 additions & 170 deletions Rubberduck.Core/app.config

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions Rubberduck.Core/packages.config
Expand Up @@ -6,8 +6,6 @@
<package id="Castle.Windsor" version="4.0.0" targetFramework="net45" />
<package id="EasyHook" version="2.7.6270" targetFramework="net45" />
<package id="HtmlAgilityPack" version="1.4.9.5" targetFramework="net45" />
<package id="LibGit2Sharp" version="0.24.0" targetFramework="net45" />
<package id="LibGit2Sharp.NativeBinaries" version="1.0.185" targetFramework="net45" />
<package id="NLog" version="4.4.12" targetFramework="net45" />
<package id="NLog.Schema" version="4.4.12" targetFramework="net45" />
<package id="System.ValueTuple" version="4.4.0" targetFramework="net45" />
Expand Down
8 changes: 7 additions & 1 deletion Rubberduck.Deployment/BuildRegistryScript.ps1
Expand Up @@ -15,13 +15,15 @@
# -wixToolsDir '$(SolutionDir)packages\WiX.Toolset.3.9.1208.0\tools\wix\'
# -sourceDir '$(TargetDir)'
# -targetDir '$(TargetDir)'
# -includeDir '$(ProjectDir)InnoSetup\Includes\'
# -filesToExtract 'Rubberduck.dll'"
param (
[Parameter(Mandatory=$true)][string]$builderAssemblyPath,
[Parameter(Mandatory=$true)][string]$netToolsDir,
[Parameter(Mandatory=$true)][string]$wixToolsDir,
[Parameter(Mandatory=$true)][string]$sourceDir,
[Parameter(Mandatory=$true)][string]$targetDir,
[Parameter(Mandatory=$true)][string]$includeDir,
[Parameter(Mandatory=$true)][string]$filesToExtract
)

Expand Down Expand Up @@ -68,7 +70,11 @@ try
# $entries | Format-Table | Out-String |% {Write-Host $_};

$writer = New-Object Rubberduck.Deployment.Writers.InnoSetupRegistryWriter
$writer.Write($entries) > ($targetDir + ($file -replace ".dll", ".reg.iss"))
$content = $writer.Write($entries);

$regFile = ($includeDir + ($file -replace ".dll", ".reg.iss"))
$Utf8NoBomEncoding = New-Object System.Text.UTF8Encoding $False
[System.IO.File]::WriteAllLines($regFile, $content, $Utf8NoBomEncoding)
}
}
catch
Expand Down
33 changes: 18 additions & 15 deletions Rubberduck.Deployment/Builders/RegistryEntryBuilder.cs
Expand Up @@ -15,6 +15,8 @@ public class RegistryEntryBuilder
private List<ClassMap> classMapList;
private Dictionary<string, List<RegistryEntry>> recordMap;

private const string baseFolder = @"Software\Classes\";

public IOrderedEnumerable<RegistryEntry> Parse(string tlbHeatOutputXmlPath, string dllHeatOutputXmlPath)
{
var tlbXml = new XmlDocument();
Expand Down Expand Up @@ -80,7 +82,7 @@ public TypeLibMap ExtractTypeLib(XmlNode node)
[HKEY_LOCAL_MACHINE\Software\Classes\TypeLib\{E07C841C-14B4-4890-83E9-8C80B06DD59D}\2.1\HELPDIR]
@="C:\\Github\\Rubberduck\\Rubberduck\\RetailCoder.VBE\\bin\\Debug"
*/
const string basePath = @"Software\Classes\TypeLib\";
const string basePath = baseFolder + @"TypeLib\";
var libGuid = node.Attributes["Id"].Value;
var libDesc = node.Attributes["Description"].Value;
var language = node.Attributes["Language"].Value;
Expand Down Expand Up @@ -145,27 +147,27 @@ public TypeLibMap ExtractTypeLib(XmlNode node)
"Version"="2.1"
*/

const string netMarshalGuid = "{00020424-0000-0000-C000-000000000046}";
const string universalMarshalerGuid = "{00020424-0000-0000-C000-000000000046}";

var guid = node.Attributes["Id"].Value;
var name = node.Attributes["Name"].Value;
var proxy = node.Attributes["ProxyStubClassId"]?.Value;
var proxy32 = node.Attributes["ProxyStubClassId32"]?.Value;

var entries = new List<RegistryEntry>();
entries.Add(new RegistryEntry($@"Interface\{guid}", null, name, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry($@"{baseFolder}Interface\{guid}", null, name, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
if (proxy != null)
{
entries.Add(new RegistryEntry($@"Interface\{guid}\{proxy}", null, netMarshalGuid,
entries.Add(new RegistryEntry($@"{baseFolder}Interface\{guid}\{proxy}", null, universalMarshalerGuid,
RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
}
if (proxy32 != null)
{
entries.Add(new RegistryEntry($@"Interface\{guid}\{proxy32}", null, netMarshalGuid,
entries.Add(new RegistryEntry($@"{baseFolder}Interface\{guid}\{proxy32}", null, universalMarshalerGuid,
RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
}
entries.Add(new RegistryEntry($@"Interface\{guid}\TypeLib", null, typeLibMap.Guid, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry($@"Interface\{guid}\TypeLib", "Version", typeLibMap.Version, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry($@"{baseFolder}Interface\{guid}\TypeLib", null, typeLibMap.Guid, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry($@"{baseFolder}Interface\{guid}\TypeLib", "Version", typeLibMap.Version, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));

dict.Add(guid, entries);
}
Expand All @@ -185,7 +187,7 @@ public TypeLibMap ExtractTypeLib(XmlNode node)
var dict = new Dictionary<string, List<RegistryEntry>>();
foreach (XmlNode node in recordList)
{
var key = node.Attributes["Key"].Value;
var key = baseFolder + node.Attributes["Key"].Value;
var name = node.Attributes["Name"].Value;
var value = node.Attributes["Value"].Value;
var type = ParseRegistryType(node.Attributes["Type"].Value);
Expand Down Expand Up @@ -233,10 +235,10 @@ public List<ClassMap> ExtractClasses(XmlNode componentXml, TypeLibMap typeLibMap
[HKEY_LOCAL_MACHINE\Software\Classes\Wow6432Node\CLSID\{28754D11-10CC-45FD-9F6A-525A65412B7A}\ProgId]
@="Rubberduck.ParserState"
*/
entries.Add(new RegistryEntry($@"CLSID\{guid}", null, description, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry($@"CLSID\{guid}\{context}", null, foreignServer, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry($@"CLSID\{guid}\{context}", "ThreadingModel", threadingModel, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry($@"CLSID\{guid}\ProgId", null, progId, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry($@"{baseFolder}CLSID\{guid}", null, description, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry($@"{baseFolder}CLSID\{guid}\{context}", null, foreignServer, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry($@"{baseFolder}CLSID\{guid}\{context}", "ThreadingModel", threadingModel, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry($@"{baseFolder}CLSID\{guid}\ProgId", null, progId, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));

foreach (XmlNode registryNode in componentXml.SelectNodes($@"//RegistryValue[starts-with(@Key, 'CLSID\{guid}')]"))
{
Expand All @@ -253,7 +255,7 @@ public List<ClassMap> ExtractClasses(XmlNode componentXml, TypeLibMap typeLibMap
<RegistryValue Root="HKCR" Key="CLSID\{28754D11-10CC-45FD-9F6A-525A65412B7A}\InprocServer32" Name="CodeBase" Value="file:///[#filEC54EFF475370C463E57905243620C96]" Type="string" Action="write" />
*/

var key = registryNode.Attributes["Key"].Value;
var key = baseFolder + registryNode.Attributes["Key"].Value;
var name = registryNode.Attributes["Name"]?.Value;
var value = registryNode.Attributes["Value"].Value;
var type = ParseRegistryType(registryNode.Attributes["Type"].Value);
Expand All @@ -269,8 +271,8 @@ public List<ClassMap> ExtractClasses(XmlNode componentXml, TypeLibMap typeLibMap
@="{28754D11-10CC-45FD-9F6A-525A65412B7A}"
*/

entries.Add(new RegistryEntry(progId, null, progIdDescription, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry(progId + @"\CLSID", null, guid, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry(baseFolder + progId, null, progIdDescription, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
entries.Add(new RegistryEntry(baseFolder + progId + @"\CLSID", null, guid, RegistryValueKind.String, Bitness.IsPlatformDependent, fileMap));
}

classMaps.Add(new ClassMap(guid, context, description, threadingModel, progId, progIdDescription, entries));
Expand Down Expand Up @@ -300,3 +302,4 @@ private RegistryValueKind ParseRegistryType(string type)
}
}
}

0 comments on commit 2e841e1

Please sign in to comment.