Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
Merge branch 'develop' into 55-config-in-cage
Browse files Browse the repository at this point in the history
  • Loading branch information
DonatJR committed Jul 5, 2018
2 parents 70555ae + 9a6bd9c commit 0eca7d7
Show file tree
Hide file tree
Showing 8 changed files with 1,995 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
!*.vcxproj
!*.vcxproj.filters
!*.csproj
!*.vdproj
!*.config
!*.settings
!*.ps1
Expand Down
4 changes: 3 additions & 1 deletion SharkCage/CageService/CageService.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_SILENCE_CXX17_ALLOCATOR_VOID_DEPRECATION_WARNING;_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
<TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>
</DisableSpecificWarnings>
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down Expand Up @@ -129,6 +129,7 @@ xcopy /y "$(OutDir)$(TargetName).pdb" "$(SolutionDir)post_build_output\"
<SDLCheck>true</SDLCheck>
<DisableSpecificWarnings>4834</DisableSpecificWarnings>
<TreatWarningAsError>true</TreatWarningAsError>
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down Expand Up @@ -178,6 +179,7 @@ xcopy /y "$(OutDir)$(TargetName).pdb" "$(SolutionDir)post_build_output\"
<SDLCheck>true</SDLCheck>
<DisableSpecificWarnings>4834</DisableSpecificWarnings>
<TreatWarningAsError>true</TreatWarningAsError>
<AdditionalOptions>/std:c++latest %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
Expand Down
66 changes: 66 additions & 0 deletions SharkCage/CageServiceInstaller/CageServiceInstaller.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration.Install;

namespace CageServiceInstaller
{
[RunInstaller(true)]
public partial class CageServiceInstaller : Installer
{
const string service_name = "shark-cage-service";

public override void Install(System.Collections.IDictionary state_saver)
{
base.Install(state_saver);
}

public override void Commit(System.Collections.IDictionary saved_state)
{
base.Commit(saved_state);

string target_dir = Context.Parameters["DP_TargetDir"].ToString();
InstallAndStartService(target_dir);
}

public override void Rollback(IDictionary saved_state)
{
base.Rollback(saved_state);
UninstallService();
}

public override void Uninstall(System.Collections.IDictionary saved_state)
{
base.Uninstall(saved_state);
UninstallService();
}

private void InstallAndStartService(string path)
{
try
{
UninstallService();
ServiceInstaller.InstallAndStart(service_name, service_name, path);
}
catch (Exception ex)
{
throw new InstallException("An exception occured while installing the service", ex);
}
}

private void UninstallService()
{
try
{
if (ServiceInstaller.ServiceIsInstalled(service_name))
{
ServiceInstaller.Uninstall(service_name);
}
}
catch (Exception ex)
{
throw new InstallException("An exception occured while uninstalling the service", ex);
}
}
}
}
52 changes: 52 additions & 0 deletions SharkCage/CageServiceInstaller/CageServiceInstaller.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?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>{E4EBEF34-9BA7-4808-90D5-6B68C5722F72}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CageServiceInstaller</RootNamespace>
<AssemblyName>CageServiceInstaller</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<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' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Configuration.Install" />
<Reference Include="System.Core" />
<Reference Include="System.ServiceProcess" />
<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="CageServiceInstaller.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ServiceInstaller.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
36 changes: 36 additions & 0 deletions SharkCage/CageServiceInstaller/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("CageServiceInstaller")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CageServiceInstaller")]
[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("e4ebef34-9ba7-4808-90d5-6b68c5722f72")]

// 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")]
Loading

0 comments on commit 0eca7d7

Please sign in to comment.