Skip to content

Commit

Permalink
Own install driver exe (#6)
Browse files Browse the repository at this point in the history
* remove old install driver stuff

* add new install driver project

* copy outputs from install driver project

* cleanup

* cleanup
  • Loading branch information
mikew authored Jul 14, 2018
1 parent 60aa801 commit be32e38
Show file tree
Hide file tree
Showing 12 changed files with 279 additions and 25 deletions.
6 changes: 6 additions & 0 deletions Install Driver/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.5.2" />
</startup>
</configuration>
58 changes: 58 additions & 0 deletions Install Driver/Install Driver.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?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>{6C663B31-ED95-43CA-9CCA-D2349F8E491E}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>Install_Driver</RootNamespace>
<AssemblyName>Install Driver</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</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">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
77 changes: 77 additions & 0 deletions Install Driver/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
namespace Install_Driver {
class Program {
static void Main (string[] args) {
InstallDriver();
SetupFirewall();
}

static void InstallDriver() {
var driverInstallerDir = System.IO.Path.Combine(
System.Environment.CurrentDirectory,
"Scp Driver Installer"
);

RunCommand(new System.Diagnostics.ProcessStartInfo {
FileName = System.IO.Path.Combine(
driverInstallerDir,
"ScpDriverInstaller.exe"
),
Arguments = "--install --quiet",
WorkingDirectory = driverInstallerDir,
});
}

static void SetupFirewall() {
RunCommand(new System.Diagnostics.ProcessStartInfo {
FileName = "netsh",
Arguments = "advfirewall firewall add rule name=\"XArcade XInput\" dir=in action=allow protocol=TCP localport=32123",
}, true);

RunCommand(new System.Diagnostics.ProcessStartInfo {
FileName = "netsh",
Arguments = "http add urlacl url=http://+:32123/ user=Everyone",
}, true);
}

static System.Diagnostics.Process RunCommand (System.Diagnostics.ProcessStartInfo startInfo, bool allowFail = false) {
System.Console.WriteLine($"Running '{startInfo.FileName} {startInfo.Arguments}'");

startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;

var proc = new System.Diagnostics.Process {
StartInfo = startInfo,
};

proc.OutputDataReceived += (sender, e) => System.Console.WriteLine(e.Data);
proc.ErrorDataReceived += (sender, e) => System.Console.WriteLine(e.Data);

try {
proc.Start();
} catch (System.Exception err) {
System.Console.WriteLine(err.Message);
WaitAndExit(1);
}

proc.BeginOutputReadLine();
proc.BeginErrorReadLine();
proc.WaitForExit();

if (!allowFail && proc.ExitCode > 0) {
System.Console.WriteLine($"Command exited with code {proc.ExitCode}");
WaitAndExit(proc.ExitCode);
}

return proc;
}

static void WaitAndExit(int exitCode) {
if (exitCode > 0) {
System.Console.WriteLine("Press any key to continue");
System.Console.ReadKey();
}
System.Environment.Exit(exitCode);
}
}
}
36 changes: 36 additions & 0 deletions Install Driver/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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("Install Driver")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Install Driver")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[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("6c663b31-ed95-43ca-9cca-d2349f8e491e")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
77 changes: 77 additions & 0 deletions Install Driver/app.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<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 element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<!-- <requestedExecutionLevel level="asInvoker" uiAccess="false" /> -->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->

<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->

<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->

<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->

<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->

</application>
</compatibility>

<!-- Indicates that the application is DPI-aware and will not be automatically scaled by Windows at higher
DPIs. Windows Presentation Foundation (WPF) applications are automatically DPI-aware and do not need
to opt in. Windows Forms applications targeting .NET Framework 4.6 that opt into this setting, should
also set the 'EnableWindowsFormsHighDpiAutoResizing' setting to 'true' in their app.config. -->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->

<!-- 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>
-->

</assembly>
9 changes: 9 additions & 0 deletions XArcade XInput.sln
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XArcade XInput", "XArcade XInput\XArcade XInput.csproj", "{2A7F171B-F9E0-42DE-B116-9F9FF812CAAA}"
ProjectSection(ProjectDependencies) = postProject
{6C663B31-ED95-43CA-9CCA-D2349F8E491E} = {6C663B31-ED95-43CA-9CCA-D2349F8E491E}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Install Driver", "Install Driver\Install Driver.csproj", "{6C663B31-ED95-43CA-9CCA-D2349F8E491E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -15,6 +20,10 @@ Global
{2A7F171B-F9E0-42DE-B116-9F9FF812CAAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2A7F171B-F9E0-42DE-B116-9F9FF812CAAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2A7F171B-F9E0-42DE-B116-9F9FF812CAAA}.Release|Any CPU.Build.0 = Release|Any CPU
{6C663B31-ED95-43CA-9CCA-D2349F8E491E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C663B31-ED95-43CA-9CCA-D2349F8E491E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C663B31-ED95-43CA-9CCA-D2349F8E491E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C663B31-ED95-43CA-9CCA-D2349F8E491E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
25 changes: 14 additions & 11 deletions XArcade XInput/XArcade XInput.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,21 +68,24 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<WebappFiles Include="..\webapp\build\**\*.*" Exclude="..\webapp\build\**\*.map"/>
<WebappFiles Include="..\webapp\build\**\*.*" Exclude="..\webapp\build\**\*.map" />
</ItemGroup>
<ItemGroup>
<MappingFiles Include="..\mappings\**\*.*"/>
<MappingFiles Include="..\mappings\**\*.*" />
</ItemGroup>
<ItemGroup>
<ScpDriverFiles Include="..\Scp Driver Installer\**\*.*"/>
<ScpDriverFiles Include="..\Scp Driver Installer\**\*.*" />
</ItemGroup>

<ItemGroup>
<OtherFiles Include="..\README.md"/>
<OtherFiles Include="..\Install Driver.exe"/>
<OtherFiles Include="..\XArcade XInput Interface.url"/>
<OtherFiles Include="..\README.md" />
<OtherFiles Include="..\XArcade XInput Interface.url" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Install Driver\Install Driver.csproj">
<Project>{6c663b31-ed95-43ca-9cca-d2349f8e491e}</Project>
<Name>Install Driver</Name>
</ProjectReference>
</ItemGroup>

<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
Expand All @@ -92,8 +95,8 @@
-->
<Target Name="AfterBuild">
<Copy SourceFiles="@(MappingFiles)" DestinationFolder="$(OutDir)mappings\%(RecursiveDir)" />
<Copy SourceFiles="@(WebappFiles)" DestinationFolder="$(OutDir)webapp\%(RecursiveDir)"/>
<Copy SourceFiles="@(ScpDriverFiles)" DestinationFolder="$(OutDir)Scp Driver Installer\%(RecursiveDir)"/>
<Copy SourceFiles="@(OtherFiles)" DestinationFolder="$(OutDir)"/>
<Copy SourceFiles="@(WebappFiles)" DestinationFolder="$(OutDir)webapp\%(RecursiveDir)" />
<Copy SourceFiles="@(ScpDriverFiles)" DestinationFolder="$(OutDir)Scp Driver Installer\%(RecursiveDir)" />
<Copy SourceFiles="@(OtherFiles)" DestinationFolder="$(OutDir)" />
</Target>
</Project>
9 changes: 0 additions & 9 deletions install.bat

This file was deleted.

3 changes: 1 addition & 2 deletions script/build.bat
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
@echo off

call script\create-install-exe.bat

REM Build webapp
rd /S /Q webapp\build\
pushd webapp\
Expand All @@ -14,6 +12,7 @@ call script\get-scp-driver-installer.bat

REM "Clean" isn't a total clean.
del /F /S /Q "XArcade XInput"\bin
rd /S /Q "XArcade XInput"\bin

REM Build Project
nuget restore
Expand Down
2 changes: 0 additions & 2 deletions script/create-install-exe.bat

This file was deleted.

2 changes: 1 addition & 1 deletion script/get-scp-driver-installer.bat
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ rd /S /Q "Scp Driver Installer"
curl -L https://github.com/mogzol/ScpDriverInterface/releases/download/1.1/ScpDriverInterface_v1.1.zip --output "Scp Driver Installer.zip"
7z x -o"ScpDriverTemp" "Scp Driver Installer.zip"
move /Y "ScpDriverTemp\Driver Installer" "Scp Driver Installer"
rd /S /Q ScpDriverTemp "Scp Driver Installer.zip"
rd /S /Q ScpDriverTemp
del /F /S /Q "Scp Driver Installer.zip"
Binary file removed vendor/Bat_To_Exe_Converter.exe
Binary file not shown.

0 comments on commit be32e38

Please sign in to comment.