Large diffs are not rendered by default.

@@ -3,8 +3,9 @@
using System;
using System.Diagnostics;
using System.Security.Principal;
using AgentInterface.Api.Win32;
using UlteriusServer.Api.Network.Models;
using UlteriusServer.Api.Win32;
using UlteriusServer.Utilities.Extensions;

#endregion

@@ -48,14 +49,18 @@ private static bool AuthMacOs(string password)
return false;
}
}

public static LoginInformation AuthWindows(string username, string password)
{
var info = new LoginInformation();
try
{

var domainName = Environment.UserDomainName;
if (username.IsValidEmail())
{
domainName = "MicrosoftAccount";
}
if (username.Contains("\\"))
{
var splitName = username.Split('\\');
@@ -15,12 +15,12 @@
using System.Threading;
using System.Threading.Tasks;
using System.Web;
using AgentInterface.Api.ScreenShare;
using AgentInterface.Api.Win32;
using AgentInterface.Settings;
using Ionic.Zip;
using NetFwTypeLib;
using Open.Nat;
using UlteriusServer.Api.Win32;
using UlteriusServer.Api.Win32.ScreenShare;
using UlteriusServer.Utilities.Extensions;
using static System.Security.Principal.WindowsIdentity;
using Task = System.Threading.Tasks.Task;

@@ -82,17 +82,14 @@ public static void RestartDaemon()
try
{
if (Process.GetProcessesByName("DaemonManager").Length != 0) return;
ProcessStarter.PROCESS_INFORMATION managerInfo;

var managerPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
"DaemonManager.exe");
ProcessStarter.StartProcessAndBypassUAC(managerPath,
out managerInfo);
managerProcess = Process.GetProcessById((int)managerInfo.dwProcessId);
managerProcess = Process.Start(managerPath);
}
catch (Exception)
{


//
}
}

@@ -111,17 +108,11 @@ public static void RestartAgent()
}

Thread.Sleep(3000);
ProcessStarter.PROCESS_INFORMATION agentInfo;


var agentPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"UlteriusAgent.exe");


var agentPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),"UlteriusAgent.exe");

ProcessStarter.StartProcessAndBypassUAC(agentPath,
out agentInfo);
agentProcess = Process.Start(agentPath);

agentProcess = Process.GetProcessById((int)agentInfo.dwProcessId);
if (agentProcess != null)
{
Console.WriteLine("Started Monitor on " + _CurrentSession);
@@ -343,10 +334,7 @@ public static void ConfigureServer()
{
Console.WriteLine("Logs Ready");
}
if (!RunningAsService())
{
ScreenData.SetupDuplication();
}
ScreenData.SetupDuplication();
if (Config.Empty)
{
if (RunningPlatform() == Platform.Windows)
@@ -361,15 +349,7 @@ public static void ConfigureServer()
var username = Environment.GetEnvironmentVariable("USERNAME");
var userdomain = Environment.GetEnvironmentVariable("USERDOMAIN");
var command = $@"/C netsh http add urlacl url={prefix} user={userdomain}\{username} listen=yes";
if (RunningAsService())
{
ProcessStarter.PROCESS_INFORMATION procInfo;
ProcessStarter.StartProcessAndBypassUAC("CMD.exe " + command, out procInfo);
}
else
{
Process.Start("CMD.exe", command);
}
Process.Start("CMD.exe", command);
OpenFirewallPort(webcamPort, "Ulterius Web Cams");
OpenFirewallPort(webServerPort, "Ulterius Web Server");
OpenFirewallPort(apiPort, "Ulterius Task Server");
@@ -399,17 +379,17 @@ private static void OpenFirewallForProgram(string exeFileName, string displayNam
{
FileName = "netsh",
Arguments =
string.Format(
"firewall add allowedprogram program=\"{0}\" name=\"{1}\" profile=\"ALL\"",
exeFileName, displayName),
$"firewall add allowedprogram program=\"{exeFileName}\" name=\"{displayName}\" profile=\"ALL\"",
WindowStyle = ProcessWindowStyle.Hidden
});
proc.WaitForExit();
proc?.WaitForExit();
}

public static bool RunningAsService()
{
return GetCurrent().Name.ToLower().Contains(@"nt authority\system");
var me = Process.GetCurrentProcess();
var parent = me.Parent();
return parent != null && parent.IsService();
}


@@ -3,7 +3,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using AgentInterface.Settings;
using UlteriusServer.Utilities.Extensions;

#endregion

This file was deleted.

@@ -10,7 +10,7 @@
using AForge.Video;
using AForge.Video.DirectShow;
using AForge.Vision.Motion;
using AgentInterface.Settings;
using UlteriusServer.Utilities;

#endregion

@@ -9,10 +9,11 @@
using System.Text;
using System.Threading;
using System.Web;
using AgentInterface.Settings;
using Newtonsoft.Json;
using UlteriusServer.Api.Services.Network;
using UlteriusServer.Properties;
using UlteriusServer.Utilities;
using UlteriusServer.Utilities.Extensions;
using UlteriusServer.Utilities.Files;
using UlteriusServer.WebServer.RemoteTaskServer.WebServer;
using File = System.IO.File;
@@ -286,13 +287,19 @@ private void Process(HttpListenerContext context)
}

filename = HttpUtility.UrlDecode(Path.Combine(_rootDirectory, filename));

if (File.Exists(filename))
{

try
{
var targetPath = Path.GetDirectoryName(new DirectoryInfo(filename).FullName);
//prevent directory traversal, we should only allow access to the root directory of the HTTP Server.
if (!targetPath.IsSubPathOf(_rootDirectory))
{
context.Response.StatusCode = (int)HttpStatusCode.Forbidden;
return;
}
Stream input = new FileStream(filename, FileMode.Open);

//Adding permanent http response headers
string mime;

@@ -26,30 +26,22 @@ namespace UlteriusServer.WebSocketAPI

public class WebSocketEventListener : IDisposable
{
private readonly List<WebSocketListener> _listeners = new List<WebSocketListener>();
private WebSocketListener _listener;

public WebSocketEventListener(List<IPEndPoint> endpoints)
public WebSocketEventListener(Uri[] endpoints)
: this(endpoints, new WebSocketListenerOptions())
{
}

public WebSocketEventListener(List<IPEndPoint> endpoints, WebSocketListenerOptions options)
public WebSocketEventListener(Uri[] endpoints, WebSocketListenerOptions options)
{
foreach (var endpoint in endpoints)
{
var listener = new WebSocketListener(endpoint, options);
var rfc6455 = new WebSocketFactoryRfc6455(listener);
listener.Standards.RegisterStandard(rfc6455);
_listeners.Add(listener);
}
options.Standards.RegisterRfc6455();
_listener = new WebSocketListener(endpoints, options);
}

public void Dispose()
{
foreach (var listener in _listeners)
{
listener.Dispose();
}
_listener?.StopAsync().GetAwaiter().GetResult();
}

public event WebSocketEventListenerOnConnect OnConnect;
@@ -58,21 +50,15 @@ public void Dispose()
public event WebSocketEventListenerOnPlainTextMessage OnPlainTextMessage;
public event WebSocketEventListenerOnError OnError;

public void Start()
public async void Start()
{
foreach (var listener in _listeners)
{
listener.Start();
}
await _listener.StartAsync();
ListenAsync();
}

public void Stop()
public async void Stop()
{
foreach (var listener in _listeners)
{
listener.Stop();
}
await _listener.StopAsync();
}

private async Task HandleListners(WebSocketListener listener)
@@ -95,10 +81,7 @@ private async Task HandleListners(WebSocketListener listener)

private void ListenAsync()
{
foreach (var listener in _listeners)
{
Task.Run(() => HandleListners(listener));
}
Task.Run(() => HandleListners(_listener));
}

private async Task HandleWebSocketAsync(WebSocket websocket)
@@ -1,27 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AForge" version="2.2.5" targetFramework="net461" />
<package id="AForge.Imaging" version="2.2.5" targetFramework="net461" />
<package id="AForge.Math" version="2.2.5" targetFramework="net461" />
<package id="AForge.Video" version="2.2.5" targetFramework="net461" />
<package id="AForge.Video.DirectShow" version="2.2.5" targetFramework="net461" />
<package id="AForge.Vision" version="2.2.5" targetFramework="net461" />
<package id="BouncyCastle" version="1.8.1" targetFramework="net461" />
<package id="Costura.Fody" version="2.0.0-beta0018" targetFramework="net461" developmentDependency="true" />
<package id="DotNetZip" version="1.10.1" targetFramework="net461" />
<package id="Fody" version="1.29.3" targetFramework="net461" developmentDependency="true" />
<package id="JonSkeet.MiscUtil" version="0.1" targetFramework="net45" />
<package id="log4net" version="2.0.7" targetFramework="net461" />
<package id="Magnum" version="2.1.3" targetFramework="net461" />
<package id="MassTransit" version="2.9.0" targetFramework="net461" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.3" targetFramework="net461" />
<package id="Microsoft.Net.Compilers" version="2.0.0-rc3" targetFramework="net461" developmentDependency="true" />
<package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net461" />
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.1-beta1" targetFramework="net461" />
<package id="Open.NAT" version="2.1.0.0" targetFramework="net461" />
<package id="System.Threading.Tasks.Dataflow" version="4.7.0" targetFramework="net461" />
<package id="Topshelf" version="4.0.3" targetFramework="net461" />
<package id="vtortola.WebSocketListener" version="2.2.2.0" targetFramework="net461" />
<package id="ZetaLongPaths" version="1.0.0.14" targetFramework="net461" />
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="AForge" version="2.2.5" targetFramework="net461" />
<package id="AForge.Imaging" version="2.2.5" targetFramework="net461" />
<package id="AForge.Math" version="2.2.5" targetFramework="net461" />
<package id="AForge.Video" version="2.2.5" targetFramework="net461" />
<package id="AForge.Video.DirectShow" version="2.2.5" targetFramework="net461" />
<package id="AForge.Vision" version="2.2.5" targetFramework="net461" />
<package id="BouncyCastle" version="1.8.1" targetFramework="net461" />
<package id="deniszykov.WebSocketListener" version="4.0.0" targetFramework="net461" />
<package id="DotNetZip" version="1.10.1" targetFramework="net461" />
<package id="JonSkeet.MiscUtil" version="0.2.0" targetFramework="net461" />
<package id="log4net" version="2.0.8" targetFramework="net461" />
<package id="Magnum" version="2.1.3" targetFramework="net461" />
<package id="MassTransit" version="2.9.0" targetFramework="net461" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.3" targetFramework="net461" />
<package id="Microsoft.Net.Compilers" version="2.4.0" targetFramework="net461" developmentDependency="true" />
<package id="Microsoft.Tpl.Dataflow" version="4.5.24" targetFramework="net461" />
<package id="Mono.Cecil" version="0.9.6.4" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" />
<package id="Open.NAT" version="2.1.0.0" targetFramework="net461" />
<package id="SharpDX" version="4.0.1" targetFramework="net461" />
<package id="SharpDX.Direct3D11" version="4.0.1" targetFramework="net461" />
<package id="SharpDX.DXGI" version="4.0.1" targetFramework="net461" />
<package id="SharpDX.Mathematics" version="4.0.1" targetFramework="net461" />
<package id="System.Threading.Tasks.Dataflow" version="4.8.0" targetFramework="net461" />
<package id="Topshelf" version="4.0.3" targetFramework="net461" />
<package id="TurboJpegWrapper" version="1.4.2.6" targetFramework="net461" />
<package id="ZetaLongPaths" version="1.0.0.19" targetFramework="net461" />
</packages>
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Magnum" publicKeyToken="b800c4cfcdeea87b" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-2.1.3.0" newVersion="2.1.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="AsyncIO" publicKeyToken="44a94435bd6f33f8" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-0.1.25.0" newVersion="0.1.25.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1"/>
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Magnum" publicKeyToken="b800c4cfcdeea87b" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.1.3.0" newVersion="2.1.3.0"/>
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="AsyncIO" publicKeyToken="44a94435bd6f33f8" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-0.1.25.0" newVersion="0.1.25.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

@@ -1,101 +1,44 @@
#region

using System;
using System.Collections.ObjectModel;
using System.Net.Security;
using System.Runtime.InteropServices;
using System.ServiceModel;
using System.ServiceModel.Channels;
using System.ServiceModel.Description;
using System.ServiceModel.Dispatcher;
using AgentInterface;
using AgentInterface.Api.ScreenShare;
using UlteriusAgent.Networking;
using Topshelf;
using Warden.Core;

#endregion

namespace UlteriusAgent
{


internal class Program
{
private const int SW_HIDE = 0;
private const int SW_SHOW = 5;

[DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();

[DllImport("kernel32.dll")]
private static extern IntPtr GetConsoleWindow();

[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);


private static void Main(string[] args)
{
if (Environment.OSVersion.Version.Major >= 6)
WardenManager.Initialize(new WardenOptions
{
SetProcessDPIAware();
}
var handle = GetConsoleWindow();

// Hide
ShowWindow(handle, SW_HIDE);

Tools.KillAllButMe();
try
DeepKill = true,
CleanOnExit = true,
ReadFileHeaders = false
});
HostFactory.Run(x => //1
{
ScreenData.SetupDuplication();
var inputAddress = "net.tcp://localhost/ulterius/agent/input/";
var frameAddress = "net.pipe://localhost/ulterius/agent/frames/";

var inputService = new ServiceHost(typeof(InputAgent));
var frameService = new ServiceHost(typeof(FrameAgent));
var inputBinding = new NetTcpBinding
{
Security = new NetTcpSecurity
{
Transport = {ProtectionLevel = ProtectionLevel.None},
Mode = SecurityMode.None
},
MaxReceivedMessageSize = int.MaxValue
};
var frameBinding = new NetNamedPipeBinding
x.Service<UlteriusAgent>(s => //2
{
Security = new NetNamedPipeSecurity
{
Transport = { ProtectionLevel = ProtectionLevel.None },
Mode = NetNamedPipeSecurityMode.None
},
MaxReceivedMessageSize = int.MaxValue
};
inputService.AddServiceEndpoint(typeof(IInputContract), inputBinding, inputAddress);
frameService.AddServiceEndpoint(typeof(IFrameContract), frameBinding, frameAddress);
inputService.Opened += delegate(object sender, EventArgs eventArgs)
{
Console.WriteLine("Input started");
};
frameService.Opened += delegate (object sender, EventArgs eventArgs)
s.ConstructUsing(name => new UlteriusAgent()); //3
s.WhenStarted(tc => tc.Start()); //4
s.WhenStopped(tc => tc.Stop());
s.WhenSessionChanged((se, e, id) => { se.HandleEvent(e, id); }); //5
});
x.OnException(ex =>
{
Console.WriteLine("Frame started");
};
inputService.Open();
frameService.Open();
Console.WriteLine("Test");
Console.Read();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message + " \n " + ex.StackTrace);
}
Console.Read();
}

private static void host_faulted(object sender, EventArgs e)
{

//TODO Logging
});
x.RunAsLocalSystem(); //6
x.EnableSessionChanged();
x.EnableServiceRecovery(r => { r.RestartService(1); });
x.SetDescription("The server that powers Ulterius"); //7
x.SetDisplayName("Ulterius Server"); //8
x.SetServiceName("UlteriusServer"); //9
x.StartAutomaticallyDelayed();
});
}
}
}
@@ -0,0 +1,107 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Topshelf;
using Warden.Core;
using Warden.Core.Utils;

namespace UlteriusAgent
{
public class UlteriusAgent
{
private readonly string _ulteriusPath;
private WardenProcess _ulteriusInstance;


public UlteriusAgent()
{
const string ulteriusFileName = "Ulterius Server.exe";
_ulteriusPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ulteriusFileName);
}

public void Start()
{
if (!File.Exists(_ulteriusPath))
{
throw new InvalidOperationException($"Unable to locate Ulterius at {_ulteriusPath}");
}
if (Respawn())
{
Console.WriteLine("Rainway started as a service!");
Console.ReadLine();
}
else
{
Console.WriteLine("Failed to start Rainway!");
Environment.Exit(1);
}
}

private bool Respawn()
{
_ulteriusInstance = null;
_ulteriusInstance = WardenProcess.Start(_ulteriusPath, string.Empty, null, true).GetAwaiter().GetResult();
if (_ulteriusInstance == null || !_ulteriusInstance.IsTreeActive())
{
return false;
}
_ulteriusInstance.OnStateChange += UlteriusInstanceOnOnStateChange;
return true;
}

public void Stop()
{
const string ulteriusFileName = "Ulterius Server.exe";
if (_ulteriusInstance != null)
{
_ulteriusInstance?.Kill();
WardenManager.Flush(_ulteriusInstance.Id);
}
_ulteriusInstance = null;
EndProcessTree(ulteriusFileName);
}

private void EndProcessTree(string imageName)
{
try
{
var taskKill = new TaskKill
{
Arguments = new List<TaskSwitch>()
{
TaskSwitch.Force,
TaskSwitch.TerminateChildren,
TaskSwitch.ImageName.SetValue(imageName)
}
};
taskKill.Execute(out var output, out var errror);
}
catch
{
//
}
}

private void UlteriusInstanceOnOnStateChange(object sender, StateEventArgs stateEventArgs)
{
if (stateEventArgs.Id == _ulteriusInstance.Id && stateEventArgs.State == ProcessState.Dead)
{
//Kill the entire tree.
_ulteriusInstance.Kill();
WardenManager.Flush(_ulteriusInstance.Id);
if (Respawn())
{
Console.WriteLine("Rainway restarted!");
}
}
}

public void HandleEvent(HostControl hostControl, SessionChangedArguments arg3)
{

}
}
}
@@ -1,121 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{686AE4C4-791F-45EB-9414-029D6115905D}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UlteriusAgent</RootNamespace>
<AssemblyName>UlteriusAgent</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</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>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.ServiceModel" />
<Reference Include="System.Windows.Forms" />
</ItemGroup>
<ItemGroup>
<Compile Include="Networking\InputAgent.cs" />
<Compile Include="Networking\FrameAgent.cs" />
<Compile Include="Networking\Tools.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="app.manifest" />
</ItemGroup>
<ItemGroup>
<None Include="FodyWeavers.xml" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\inputsimulator2\WindowsInput\WindowsInput.csproj">
<Project>{3549cd6f-80f8-450f-b99e-cf0a736b1f2a}</Project>
<Name>WindowsInput</Name>
</ProjectReference>
<ProjectReference Include="..\AgentInterface\AgentInterface.csproj">
<Project>{5c3b0b17-cbb7-4b4b-b527-1fab2bb96466}</Project>
<Name>AgentInterface</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<UsingTask TaskName="CosturaCleanup" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" TaskFactory="CodeTaskFactory">
<ParameterGroup>
<Config Output="false" Required="true" ParameterType="Microsoft.Build.Framework.ITaskItem" />
<Files Output="false" Required="true" ParameterType="Microsoft.Build.Framework.ITaskItem[]" />
</ParameterGroup>
<Task Evaluate="true">
<Reference xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Include="System.Xml" />
<Reference xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Include="System.Xml.Linq" />
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System" />
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.IO" />
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.Xml.Linq" />
<Code xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Type="Fragment" Language="cs"><![CDATA[
var config = XElement.Load(Config.ItemSpec).Elements("Costura").FirstOrDefault();
if (config == null) return true;
var excludedAssemblies = new List<string>();
var attribute = config.Attribute("ExcludeAssemblies");
if (attribute != null)
foreach (var item in attribute.Value.Split('|').Select(x => x.Trim()).Where(x => x != string.Empty))
excludedAssemblies.Add(item);
var element = config.Element("ExcludeAssemblies");
if (element != null)
foreach (var item in element.Value.Split(new[] { "\r\n", "\n" }, StringSplitOptions.RemoveEmptyEntries).Select(x => x.Trim()).Where(x => x != string.Empty))
excludedAssemblies.Add(item);
var filesToCleanup = Files.Select(f => f.ItemSpec).Where(f => !excludedAssemblies.Contains(Path.GetFileNameWithoutExtension(f), StringComparer.InvariantCultureIgnoreCase));
foreach (var item in filesToCleanup)
File.Delete(item);
]]></Code>
</Task>
</UsingTask>
<Target Name="CleanReferenceCopyLocalPaths" AfterTargets="AfterBuild;NonWinFodyTarget">
<CosturaCleanup Config="FodyWeavers.xml" Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />
</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>
-->
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.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>{686AE4C4-791F-45EB-9414-029D6115905D}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>UlteriusAgent</RootNamespace>
<AssemblyName>UlteriusAgent</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</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>
<LangVersion>7</LangVersion>
</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>
<Prefer32Bit>false</Prefer32Bit>
<LangVersion>7</LangVersion>
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="Topshelf, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b800c4cfcdeea87b, processorArchitecture=MSIL">
<HintPath>..\packages\Topshelf.4.0.3\lib\net452\Topshelf.dll</HintPath>
</Reference>
<Reference Include="Warden, Version=1.2.3.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\Warden.NET.1.2.3\lib\net45\Warden.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UlteriusAgent.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="app.manifest" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Topshelf" version="4.0.3" targetFramework="net452" />
<package id="Warden.NET" version="1.2.3" targetFramework="net452" />
</packages>
@@ -1,49 +1,44 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UlteriusServer", "RemoteTaskServer\UlteriusServer.csproj", "{E9A365D5-AEBE-4AF3-86C5-D17BC65ADE46}"
ProjectSection(ProjectDependencies) = postProject
{5C3B0B17-CBB7-4B4B-B527-1FAB2BB96466} = {5C3B0B17-CBB7-4B4B-B527-1FAB2BB96466}
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A} = {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}
{686AE4C4-791F-45EB-9414-029D6115905D} = {686AE4C4-791F-45EB-9414-029D6115905D}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UlteriusAgent", "UlteriusAgent\UlteriusAgent.csproj", "{686AE4C4-791F-45EB-9414-029D6115905D}"
ProjectSection(ProjectDependencies) = postProject
{5C3B0B17-CBB7-4B4B-B527-1FAB2BB96466} = {5C3B0B17-CBB7-4B4B-B527-1FAB2BB96466}
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A} = {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AgentInterface", "AgentInterface\AgentInterface.csproj", "{5C3B0B17-CBB7-4B4B-B527-1FAB2BB96466}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsInput", "..\inputsimulator2\WindowsInput\WindowsInput.csproj", "{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E9A365D5-AEBE-4AF3-86C5-D17BC65ADE46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9A365D5-AEBE-4AF3-86C5-D17BC65ADE46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9A365D5-AEBE-4AF3-86C5-D17BC65ADE46}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9A365D5-AEBE-4AF3-86C5-D17BC65ADE46}.Release|Any CPU.Build.0 = Release|Any CPU
{686AE4C4-791F-45EB-9414-029D6115905D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{686AE4C4-791F-45EB-9414-029D6115905D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{686AE4C4-791F-45EB-9414-029D6115905D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{686AE4C4-791F-45EB-9414-029D6115905D}.Release|Any CPU.Build.0 = Release|Any CPU
{5C3B0B17-CBB7-4B4B-B527-1FAB2BB96466}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C3B0B17-CBB7-4B4B-B527-1FAB2BB96466}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C3B0B17-CBB7-4B4B-B527-1FAB2BB96466}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5C3B0B17-CBB7-4B4B-B527-1FAB2BB96466}.Release|Any CPU.Build.0 = Release|Any CPU
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2005
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UlteriusServer", "RemoteTaskServer\UlteriusServer.csproj", "{E9A365D5-AEBE-4AF3-86C5-D17BC65ADE46}"
ProjectSection(ProjectDependencies) = postProject
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A} = {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}
{686AE4C4-791F-45EB-9414-029D6115905D} = {686AE4C4-791F-45EB-9414-029D6115905D}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UlteriusAgent", "UlteriusAgent\UlteriusAgent.csproj", "{686AE4C4-791F-45EB-9414-029D6115905D}"
ProjectSection(ProjectDependencies) = postProject
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A} = {3549CD6F-80F8-450F-B99E-CF0A736B1F2A}
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WindowsInput", "..\..\..\inputsimulator2\WindowsInput\WindowsInput.csproj", "{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E9A365D5-AEBE-4AF3-86C5-D17BC65ADE46}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{E9A365D5-AEBE-4AF3-86C5-D17BC65ADE46}.Debug|Any CPU.Build.0 = Debug|Any CPU
{E9A365D5-AEBE-4AF3-86C5-D17BC65ADE46}.Release|Any CPU.ActiveCfg = Release|Any CPU
{E9A365D5-AEBE-4AF3-86C5-D17BC65ADE46}.Release|Any CPU.Build.0 = Release|Any CPU
{686AE4C4-791F-45EB-9414-029D6115905D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{686AE4C4-791F-45EB-9414-029D6115905D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{686AE4C4-791F-45EB-9414-029D6115905D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{686AE4C4-791F-45EB-9414-029D6115905D}.Release|Any CPU.Build.0 = Release|Any CPU
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3549CD6F-80F8-450F-B99E-CF0A736B1F2A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9CC02739-8FB9-4530-9C74-0436AF2D60A7}
EndGlobalSection
EndGlobal