Skip to content

Commit

Permalink
Add Installer project
Browse files Browse the repository at this point in the history
- Fixed build directory
  • Loading branch information
MakotoUwaya committed Aug 25, 2024
1 parent aa390c1 commit 61909e8
Show file tree
Hide file tree
Showing 7 changed files with 257 additions and 1 deletion.
6 changes: 6 additions & 0 deletions Installer/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.8" />
</startup>
</configuration>
57 changes: 57 additions & 0 deletions Installer/Installer.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?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>{ADDF68C2-D65A-4830-A2C3-CCBD85536266}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Installer</RootNamespace>
<AssemblyName>Installer</AssemblyName>
<TargetFrameworkVersion>v4.8</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>
<ApplicationManifest>app.manifest</ApplicationManifest>
</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="app.manifest" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
99 changes: 99 additions & 0 deletions Installer/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
using System;
using System.IO;
using Microsoft.Win32;

namespace Installer
{

/// <summary>
/// Entry point for the installer.
/// </summary>
class Program
{

const string URI_SCHEME = "mukwty-wpf";
const string URI_KEY = "URL:mukwty Protocol";

static void RegisterUriScheme(string appPath)
{
// HKEY_CLASSES_ROOT\es-one-desktop-test
using (var hkcrClass = Registry.ClassesRoot.CreateSubKey(URI_SCHEME))
{
hkcrClass.SetValue(null, URI_KEY);
hkcrClass.SetValue("URL Protocol", string.Empty, RegistryValueKind.String);

// use the application's icon as the URI scheme icon
using (var defaultIcon = hkcrClass.CreateSubKey("DefaultIcon"))
{
var iconValue = string.Format("\"{0}\",0", appPath);
defaultIcon.SetValue(null, iconValue);
}

// open the application and pass the URI to the command-line
using (var shell = hkcrClass.CreateSubKey("shell"))
{
using (var open = shell.CreateSubKey("open"))
{
using (var command = open.CreateSubKey("command"))
{
var cmdValue = string.Format("\"{0}\" \"%1\"", appPath);
command.SetValue(null, cmdValue);
}
}
}
}
}

static void UnregisterUriScheme()
{
Registry.ClassesRoot.DeleteSubKeyTree(URI_SCHEME);
}

static void Main(string[] args)
{
if ((args.Length > 0) && (args[0].Equals("/u") || args[0].Equals("-u")))
{
// uninstall
Console.Write("Attempting to unregister URI scheme...");

try
{
UnregisterUriScheme();
Console.WriteLine(" Success.");
}
catch (Exception ex)
{
Console.WriteLine(" Failed!");
Console.WriteLine("{0}: {1}", ex.GetType().Name, ex.Message);
}
}
else
{
// install
var appPath = Path.Combine(Path.GetDirectoryName(typeof(Program).Assembly.Location), "MultiProcessWPF.exe");

Console.Write("Attempting to register URI scheme...");

try
{
if (!File.Exists(appPath))
{
throw new InvalidOperationException(string.Format("Application not found at: {0}", appPath));
}

RegisterUriScheme(appPath);
Console.WriteLine(" Success.");
}
catch (Exception ex)
{
Console.WriteLine(" Failed!");
Console.WriteLine("{0}: {1}", ex.GetType().Name, ex.Message);
}
}

Console.WriteLine();
Console.WriteLine("Press any key to continue...");
Console.ReadKey();
}
}
}
33 changes: 33 additions & 0 deletions Installer/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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("Installer")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Installer")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// 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("addf68c2-d65a-4830-a2c3-ccbd85536266")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
55 changes: 55 additions & 0 deletions Installer/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel node will disable file and registry virtualization.
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of all Windows versions that this application is designed to work with.
Windows will automatically select the most compatible environment.-->

<!-- If your application is designed to work with Windows Vista, uncomment the following supportedOS node-->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>-->

<!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->

<!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->

</application>
</compatibility>

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!-- <dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->

</asmv1:assembly>
6 changes: 6 additions & 0 deletions MultiProcessWPF.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ VisualStudioVersion = 17.11.35219.272
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MultiProcessWPF", "MultiProcessWPF\MultiProcessWPF.csproj", "{52ABA8EF-C38C-4615-AA09-DC0A40786204}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Installer", "Installer\Installer.csproj", "{ADDF68C2-D65A-4830-A2C3-CCBD85536266}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -15,6 +17,10 @@ Global
{52ABA8EF-C38C-4615-AA09-DC0A40786204}.Debug|Any CPU.Build.0 = Debug|Any CPU
{52ABA8EF-C38C-4615-AA09-DC0A40786204}.Release|Any CPU.ActiveCfg = Release|Any CPU
{52ABA8EF-C38C-4615-AA09-DC0A40786204}.Release|Any CPU.Build.0 = Release|Any CPU
{ADDF68C2-D65A-4830-A2C3-CCBD85536266}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ADDF68C2-D65A-4830-A2C3-CCBD85536266}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ADDF68C2-D65A-4830-A2C3-CCBD85536266}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ADDF68C2-D65A-4830-A2C3-CCBD85536266}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion MultiProcessWPF/MultiProcessWPF.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<OutputPath>..\bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
Expand Down

0 comments on commit 61909e8

Please sign in to comment.