Skip to content

Commit

Permalink
Added installer for fiddler extension (#177)
Browse files Browse the repository at this point in the history
  • Loading branch information
SteveSyfuhs authored Aug 8, 2020
1 parent 8b02057 commit 2915c7d
Show file tree
Hide file tree
Showing 12 changed files with 379 additions and 4 deletions.
12 changes: 12 additions & 0 deletions Fiddler.Kerberos.NET/Fiddler.Kerberos.NET.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ VisualStudioVersion = 16.0.30225.117
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Fiddler.Kerberos.NET", "Fiddler.Kerberos.NET\Fiddler.Kerberos.NET.csproj", "{4B76BD9D-C771-45CC-BC4A-5702B3DBD11E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "InstallHost", "InstallHost\InstallHost.csproj", "{2B5D7B76-A951-4DF5-B0A6-2A110FF194D2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KerberosInstaller", "KerberosInstaller\KerberosInstaller.csproj", "{9686F73F-5526-4C9A-B603-C7ACBFCB1976}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +19,14 @@ Global
{4B76BD9D-C771-45CC-BC4A-5702B3DBD11E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4B76BD9D-C771-45CC-BC4A-5702B3DBD11E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4B76BD9D-C771-45CC-BC4A-5702B3DBD11E}.Release|Any CPU.Build.0 = Release|Any CPU
{2B5D7B76-A951-4DF5-B0A6-2A110FF194D2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2B5D7B76-A951-4DF5-B0A6-2A110FF194D2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2B5D7B76-A951-4DF5-B0A6-2A110FF194D2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2B5D7B76-A951-4DF5-B0A6-2A110FF194D2}.Release|Any CPU.Build.0 = Release|Any CPU
{9686F73F-5526-4C9A-B603-C7ACBFCB1976}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9686F73F-5526-4C9A-B603-C7ACBFCB1976}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9686F73F-5526-4C9A-B603-C7ACBFCB1976}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9686F73F-5526-4C9A-B603-C7ACBFCB1976}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,33 @@
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="FiddlerKerberosNET.nuspec" />
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\InstallHost\InstallHost.csproj">
<Project>{2b5d7b76-a951-4df5-b0a6-2a110ff194d2}</Project>
<Name>InstallHost</Name>
</ProjectReference>
<ProjectReference Include="..\KerberosInstaller\KerberosInstaller.csproj">
<Project>{9686f73f-5526-4c9a-b603-c7acbfcb1976}</Project>
<Name>KerberosInstaller</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>XCOPY "$(TargetDir)*.dll" "%25userprofile%25\Documents\Fiddler2\Inspectors\" /S /Y
XCOPY "$(TargetDir)*.pdb" "%25userprofile%25\Documents\Fiddler2\Inspectors\" /S /Y
XCOPY "$(TargetPath)" "%25userprofile%25\Documents\Fiddler2\Scripts\" /S /Y</PostBuildEvent>
<PostBuildEvent>rem XCOPY "$(TargetDir)*.dll" "%25userprofile%25\Documents\Fiddler2\Inspectors\" /S /Y
rem XCOPY "$(TargetDir)*.pdb" "%25userprofile%25\Documents\Fiddler2\Inspectors\" /S /Y
rem XCOPY "$(TargetPath)" "%25userprofile%25\Documents\Fiddler2\Scripts\" /S /Y</PostBuildEvent>
</PropertyGroup>
<PropertyGroup>
<PreBuildEvent>taskkill /im fiddler.exe /t /f 2&gt;&amp;1 | exit /B 0</PreBuildEvent>
</PropertyGroup>
<Target Name="AfterBuild" Condition=" '$(Configuration)' == 'Release'">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="myAssemblyInfo" />
</GetAssemblyIdentity>
<Exec Command="nuget pack FiddlerKerberosNet.nuspec -Version %(myAssemblyInfo.Version) -Properties Configuration=Release -OutputDirectory $(OutDir) -BasePath $(OutDir)" />
<Exec Command="squirrel --releasify $(OutDir)FiddlerKerberosNet.$([System.Version]::Parse(%(myAssemblyInfo.Version)).ToString(3)).nupkg" />
</Target>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>FiddlerKerberosNET</id>
<version>4.0.1</version>
<title>Kerberos.NET Fiddler Extension</title>
<authors>Kerberos.NET</authors>
<owners>.NET Foundation</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>A Fiddler extension that parses Kerberos messages using the Kerberos.NET library.</description>
</metadata>
<files>
<file src="DeltaCompressionDotNet.dll" target="lib\net45\DeltaCompressionDotNet.dll" />
<file src="DeltaCompressionDotNet.MsDelta.dll" target="lib\net45\DeltaCompressionDotNet.MsDelta.dll" />
<file src="DeltaCompressionDotNet.PatchApi.dll" target="lib\net45\DeltaCompressionDotNet.PatchApi.dll" />
<file src="Fiddler.Kerberos.NET.dll" target="lib\net45\Fiddler.Kerberos.NET.dll" />
<file src="InstallHost.exe" target="lib\net45\InstallHost.exe" />
<file src="KerberosInstaller.dll" target="lib\net45\KerberosInstaller.dll" />
<file src="Kerberos.NET.dll" target="lib\net45\Kerberos.NET.dll" />
<file src="Microsoft.Extensions.Logging.Abstractions.dll" target="lib\net45\Microsoft.Extensions.Logging.Abstractions.dll" />
<file src="Mono.Cecil.dll" target="lib\net45\Mono.Cecil.dll" />
<file src="Mono.Cecil.Mdb.dll" target="lib\net45\Mono.Cecil.Mdb.dll" />
<file src="Mono.Cecil.Pdb.dll" target="lib\net45\Mono.Cecil.Pdb.dll" />
<file src="Mono.Cecil.Rocks.dll" target="lib\net45\Mono.Cecil.Rocks.dll" />
<file src="Newtonsoft.Json.dll" target="lib\net45\Newtonsoft.Json.dll" />
<file src="NuGet.Squirrel.dll" target="lib\net45\NuGet.Squirrel.dll" />
<file src="SharpCompress.dll" target="lib\net45\SharpCompress.dll" />
<file src="Splat.dll" target="lib\net45\Splat.dll" />
<file src="Squirrel.dll" target="lib\net45\Squirrel.dll" />
<file src="System.Buffers.dll" target="lib\net45\System.Buffers.dll" />
<file src="System.IO.Pipelines.dll" target="lib\net45\System.IO.Pipelines.dll" />
<file src="System.Memory.dll" target="lib\net45\System.Memory.dll" />
<file src="System.Numerics.Vectors.dll" target="lib\net45\System.Numerics.Vectors.dll" />
<file src="System.Runtime.CompilerServices.Unsafe.dll" target="lib\net45\System.Runtime.CompilerServices.Unsafe.dll" />
<file src="System.Security.Cryptography.Pkcs.dll" target="lib\net45\System.Security.Cryptography.Pkcs.dll" />
<file src="System.Threading.Tasks.Extensions.dll" target="lib\net45\System.Threading.Tasks.Extensions.dll" />
</files>
</package>
15 changes: 14 additions & 1 deletion Fiddler.Kerberos.NET/Fiddler.Kerberos.NET/KerberosInspector.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
using System.Windows.Forms;
using System;
using System.Windows.Forms;

namespace Fiddler.Kerberos.NET
{
public abstract class KerberosInspector : Inspector2
{
protected KerberosInspector()
{
try
{
InstallManager.Watch();
}
catch (Exception ex)
{
FiddlerApplication.Log.LogString("Kerberos Inspector Update Exception: " + ex.ToString());
}
}

protected KerberosMessageView View { get; } = new KerberosMessageView();

public override void AddToTab(TabPage o)
Expand Down
6 changes: 6 additions & 0 deletions Fiddler.Kerberos.NET/InstallHost/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>
71 changes: 71 additions & 0 deletions Fiddler.Kerberos.NET/InstallHost/InstallHost.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2B5D7B76-A951-4DF5-B0A6-2A110FF194D2}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>InstallHost</RootNamespace>
<AssemblyName>InstallHost</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>false</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>key.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="key.snk" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="squirrel.windows">
<Version>1.9.1</Version>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\KerberosInstaller\KerberosInstaller.csproj">
<Project>{9686f73f-5526-4c9a-b603-c7acbfcb1976}</Project>
<Name>KerberosInstaller</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
10 changes: 10 additions & 0 deletions Fiddler.Kerberos.NET/InstallHost/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace Fiddler.Kerberos.NET
{
class Program
{
static void Main(string[] args)
{
InstallManager.Setup();
}
}
}
25 changes: 25 additions & 0 deletions Fiddler.Kerberos.NET/InstallHost/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("InstallHost")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("InstallHost")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

[assembly: AssemblyMetadata("SquirrelAwareVersion", "1")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("2b5d7b76-a951-4df5-b0a6-2a110ff194d2")]
Binary file added Fiddler.Kerberos.NET/InstallHost/key.snk
Binary file not shown.
103 changes: 103 additions & 0 deletions Fiddler.Kerberos.NET/KerberosInstaller/InstallManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using System;
using System.IO;
using System.Reflection;
using System.Threading.Tasks;
using Squirrel;

namespace Fiddler.Kerberos.NET
{
public static class InstallManager
{
public static void Setup()
{
SquirrelAwareApp.HandleEvents(
onInitialInstall: v => CopyFiles(),
onAppUpdate: v => CopyFiles(),
onAppUninstall: v => DeleteFiles(),
onFirstRun: () => { }
);
}

private static bool running;

public static void Watch()
{
if (running)
{
return;
}

running = true;

Task.Run(Update);
}

private static async Task Update()
{
try
{
using (var mgr = await UpdateManager.GitHubUpdateManager("https://github.com/dotnet/Kerberos.NET"))
{
await mgr.UpdateApp();
}
}
catch
{
return;
}
}

private static void DeleteFiles()
{
var files = GetPluginFiles();

foreach (var file in files)
{
var name = Path.GetFileName(file);

var inspectorPath = GetInspectorPath(name);

try
{
if (File.Exists(inspectorPath))
{
File.Delete(inspectorPath);
}
}
catch
{
;
}
}
}

private static void CopyFiles()
{
string[] files = GetPluginFiles();

foreach (var file in files)
{
var name = Path.GetFileName(file);
var targetPath = GetInspectorPath(name);

File.Copy(
file,
targetPath,
overwrite: true
);
}
}

private static string GetInspectorPath(string file)
{
return Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + $"\\fiddler2\\inspectors\\{file}";
}

private static string[] GetPluginFiles()
{
var directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

return Directory.GetFiles(directory, "*.dll");
}
}
}
Loading

0 comments on commit 2915c7d

Please sign in to comment.