Add a server project

This commit is contained in:
Ben Olden-Cooligan 2018-09-22 12:50:19 -04:00
parent 7adba5be50
commit 20ca7d19c2
8 changed files with 274 additions and 1 deletions

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
using NAPS2.DI.Modules;
using NAPS2.Util;
using NAPS2.Worker;
using Ninject;
namespace NAPS2.DI.EntryPoints
{
/// <summary>
/// The entry point for NAPS2.Server.exe, which exposes scanning devices over the network to other NAPS2 applications.
/// </summary>
public static class ServerEntryPoint
{
public static void Run(string[] args)
{
try
{
// Initialize Ninject (the DI framework)
var kernel = new StandardKernel(new CommonModule(), new WinFormsModule());
// Set up basic application configuration
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.ThreadException += UnhandledException;
// Set up a form for the server process
var form = new BackgroundForm();
Invoker.Current = form;
// TODO: Listen for requests
}
catch (Exception ex)
{
Log.FatalException("An error occurred that caused the server application to close.", ex);
Environment.Exit(1);
}
}
private static void UnhandledException(object sender, ThreadExceptionEventArgs threadExceptionEventArgs)
{
Log.FatalException("An error occurred that caused the server to close.", threadExceptionEventArgs.Exception);
}
}
}

View File

@ -81,6 +81,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="EntryPoints\ConsoleEntryPoint.cs" />
<Compile Include="EntryPoints\ServerEntryPoint.cs" />
<Compile Include="EntryPoints\WorkerEntryPoint.cs" />
<Compile Include="Modules\CommonModule.cs" />
<Compile Include="Modules\ConsoleModule.cs" />
@ -121,5 +122,5 @@
<Target Name="AfterBuild">
</Target>
-->
<Import Project="..\NAPS2\Setup\CommonTargets.targets"/>
<Import Project="..\NAPS2\Setup\CommonTargets.targets" />
</Project>

31
NAPS2.Server/.gitignore vendored Normal file
View File

@ -0,0 +1,31 @@
Thumbs.db
*.obj
*.exe
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.sln.docstates
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
*.vssscc
$tf*/
publish/
bin/

16
NAPS2.Server/App.config Normal file
View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="lib" />
<dependentAssembly>
<assemblyIdentity name="System.Runtime" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Threading.Tasks" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.6.8.0" newVersion="2.6.8.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client" /></startup></configuration>

View File

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" 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>{BC0E3031-6C00-4707-A424-4FF04425D719}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>NAPS2.Server</RootNamespace>
<AssemblyName>NAPS2.Server</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<LangVersion>latest</LangVersion>
</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)' == 'InstallerEXE|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\InstallerEXE\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'InstallerMSI|AnyCPU'">
<OutputPath>bin\InstallerMSI\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>latest</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Standalone|AnyCPU'">
<OutputPath>bin\Standalone\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<LangVersion>latest</LangVersion>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Threading.Tasks, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions, Version=1.0.12.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Threading.Tasks.Extensions.Desktop, Version=1.0.168.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.Async.1.0.168\lib\net40\Microsoft.Threading.Tasks.Extensions.Desktop.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.IO, Version=2.6.8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.IO.dll</HintPath>
</Reference>
<Reference Include="System.Net" />
<Reference Include="System.Runtime, Version=2.6.8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Threading.Tasks, Version=2.6.8.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Bcl.1.1.8\lib\net40\System.Threading.Tasks.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs">
<SubType>
</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NAPS2.Core\NAPS2.Core.csproj">
<Project>{968378fa-a649-4058-a928-1fcd97b23070}</Project>
<Name>NAPS2.Core</Name>
</ProjectReference>
<ProjectReference Include="..\NAPS2.DI\NAPS2.DI.csproj">
<Project>{4d349529-149b-498b-8a55-373e6a67e1f0}</Project>
<Name>NAPS2.DI</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets" Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" />
<Target Name="EnsureBclBuildImported" BeforeTargets="BeforeBuild" Condition="'$(BclBuildImported)' == ''">
<Error Condition="!Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="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=317567." HelpKeyword="BCLBUILD2001" />
<Error Condition="Exists('..\packages\Microsoft.Bcl.Build.1.0.14\tools\Microsoft.Bcl.Build.targets')" Text="The build restored NuGet packages. Build the project again to include these packages in the build. For more information, see http://go.microsoft.com/fwlink/?LinkID=317568." HelpKeyword="BCLBUILD2002" />
</Target>
<!-- 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">
</Target>
<Target Name="AfterBuild">
</Target>
-->
<Import Project="..\NAPS2\Setup\CommonTargets.targets" />
</Project>

20
NAPS2.Server/Program.cs Normal file
View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using NAPS2.DI.EntryPoints;
namespace NAPS2.Server
{
static class Program
{
/// <summary>
/// The NAPS2.Server.exe main method.
/// </summary>
[STAThread]
static void Main(string[] args)
{
// Use reflection to avoid antivirus false positives (yes, really)
typeof(ServerEntryPoint).GetMethod("Run").Invoke(null, new object[] { args });
}
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl" version="1.1.8" targetFramework="net40-client" />
<package id="Microsoft.Bcl.Async" version="1.0.168" targetFramework="net40-client" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net40-client" />
</packages>

View File

@ -33,6 +33,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAPS2.Worker", "NAPS2.Worke
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAPS2.Localization", "NAPS2.Localization\NAPS2.Localization.csproj", "{F6CD6C88-49EA-4443-BB45-69FB79788C61}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NAPS2.Server", "NAPS2.Server\NAPS2.Server.csproj", "{BC0E3031-6C00-4707-A424-4FF04425D719}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
@ -126,6 +128,16 @@ Global
{F6CD6C88-49EA-4443-BB45-69FB79788C61}.InstallerMSI|x86.Build.0 = Debug|Any CPU
{F6CD6C88-49EA-4443-BB45-69FB79788C61}.Standalone|x86.ActiveCfg = Debug|Any CPU
{F6CD6C88-49EA-4443-BB45-69FB79788C61}.Standalone|x86.Build.0 = Debug|Any CPU
{BC0E3031-6C00-4707-A424-4FF04425D719}.Debug|x86.ActiveCfg = Debug|Any CPU
{BC0E3031-6C00-4707-A424-4FF04425D719}.Debug|x86.Build.0 = Debug|Any CPU
{BC0E3031-6C00-4707-A424-4FF04425D719}.DebugLang|x86.ActiveCfg = Debug|Any CPU
{BC0E3031-6C00-4707-A424-4FF04425D719}.DebugLang|x86.Build.0 = Debug|Any CPU
{BC0E3031-6C00-4707-A424-4FF04425D719}.InstallerEXE|x86.ActiveCfg = InstallerEXE|Any CPU
{BC0E3031-6C00-4707-A424-4FF04425D719}.InstallerEXE|x86.Build.0 = InstallerEXE|Any CPU
{BC0E3031-6C00-4707-A424-4FF04425D719}.InstallerMSI|x86.ActiveCfg = InstallerMSI|Any CPU
{BC0E3031-6C00-4707-A424-4FF04425D719}.InstallerMSI|x86.Build.0 = InstallerMSI|Any CPU
{BC0E3031-6C00-4707-A424-4FF04425D719}.Standalone|x86.ActiveCfg = Standalone|Any CPU
{BC0E3031-6C00-4707-A424-4FF04425D719}.Standalone|x86.Build.0 = Standalone|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE