Compare commits

..

10 Commits

Author SHA1 Message Date
Carl Kittelberger 163f231cee Update EasyInstall_Windows.md
- Added Microsoft Build Tools 2013 reference
2015-01-21 10:09:41 +01:00
Icedream d0d8779b88 Updating documents. 2015-01-16 12:11:32 +01:00
Icedream 294d39edb7 Update libgit2 Linux binaries. Closes #2. 2015-01-16 10:57:32 +01:00
Icedream 1cea040c48 Remove assembly load debug lines. 2015-01-16 10:42:35 +01:00
Icedream 853140b905 Emulate xbuild targeting behavior on Mono. Closes #1.
- Added subprocess startup with assembly binding redirection to enforce MSBuild version 12 system (https://github.com/mono/mono/blob/master/mcs/tools/xbuild/data/xbuild.exe.config.in). I don't know how many nasty side effects this causes as the code is pretty poor, so pleeeeeaaaaaase do report bugs on this.
2015-01-16 10:35:58 +01:00
Icedream 364fee11dd Return exit values through wrapper. 2015-01-16 10:25:16 +01:00
Icedream e5d1675ee6 Merge remote-tracking branch 'origin/master' into develop 2015-01-15 09:04:50 +01:00
Icedream 14ed7085e0 Updating libgit2 Linux binaries. These ones were built on Debian Squeeze, should solve the issue with GLIBC, for real. 2015-01-15 08:55:37 +01:00
Icedream 80727029d6 Upgrade target to .NET Framework 4.5. Related to #1. 2015-01-14 23:02:45 +01:00
Carl Kittelberger bfac6bc5a6 Update Terminal_Linux.md
Replaced wrong link.
2015-01-14 10:03:27 +01:00
16 changed files with 225 additions and 97 deletions

View File

@ -8,30 +8,27 @@ Updates, compiles and sets up your CitizenMP server automagically!
Features Features
-------- --------
- Compatible with both Microsoft .NET Framework and Mono (Mac OS X support planned) - Compatible with both Microsoft .NET Framework 4.5+ and Mono 3.0+ (Mac OS X support planned)
- Creates ready-to-use start scripts for your platform - Creates ready-to-use start scripts for your platform
- No extra setup besides usual requirements needed - No extra setup besides requirements listed below needed
Requirements Requirements
------------ ------------
First of all, you'll need Windows or Linux to run this tool. Currently, since no libgit2 binaries can be provided for Mac OS X, this tool won't work there. Here's the guaranteed compatible list of OS this tool can be run on: First of all, you'll need Windows or Linux to run this tool. Currently, since no libgit2 binaries can be provided for Mac OS X, this tool won't work there. Here's the guaranteed compatible list of OS this tool can be run on:
- Ubuntu 12.04 (old LTS) or higher, including 14.xx - Ubuntu 12.04 LTS or higher, including 14.xx
- Debian 7.x (Wheezy) or higher, including testing and sid installations - Debian 7.x (Wheezy) or higher, including testing and sid installations
- Every other currently stable Linux distribution should work just fine as well - Every other currently stable Linux distribution with up-to-date Mono
- Any Windows operating system with .NET Framework 4 Full on it - Any Windows operating system with .NET Framework 4.5 Full on it
To run this program and the resulting server, you need the following components: To run this program and the resulting server, you need the following components:
- _On Windows:_ .NET Framework 4 or newer - _On Windows:_ .NET Framework 4.5 or newer ([Download](http://microsoft.com/download/details.aspx?id=30653))
- _On Linux:_ Mono 2.10.x/3.x or newer - _On Linux:_ Mono 3.x or newer, runtime + xbuild files ([Installation instructions](http://www.mono-project.com/docs/getting-started/install/linux/))
On Ubuntu and Debian you can just install all requirements with this command: *Note that Mono 2.10.x/.NET 4 are not supported!*
If you use a Debian-based distribution that still only offers Mono binaries older than 3.x, you must [switch to Xamarin's Debian repository](http://www.mono-project.com/docs/getting-started/install/linux/).
```
sudo apt-get install mono-runtime libmono-system-core4.0-cil
```
Guides Guides
------ ------
@ -45,7 +42,7 @@ Usage
This tool ships with a usage screen that will be printed if this tool is run without arguments. It looks similar to the following: This tool ships with a usage screen that will be printed if this tool is run without arguments. It looks similar to the following:
``` ```
CitizenMP Server Updater 1.0.1+Branch.master.Sha.4475e9becd5fa22563a92fe202f8df21329969fc CitizenMP Server Updater 1.0.3
© 2014-2015 Carl Kittelberger © 2014-2015 Carl Kittelberger
This is free software. You may redistribute copies of it under the terms of the MIT License <http://www.opensource.org/licenses/mit-license.php>. This is free software. You may redistribute copies of it under the terms of the MIT License <http://www.opensource.org/licenses/mit-license.php>.

View File

@ -3,10 +3,11 @@ Easy server installation on Windows
On Windows, you can mostly avoid using the command line for easy usage. Instead, just drag and drop an empty folder onto it. Below is a detailed explanation: On Windows, you can mostly avoid using the command line for easy usage. Instead, just drag and drop an empty folder onto it. Below is a detailed explanation:
1. Make sure at least .NET Framework 4 is installed on your server computer. If not, you can download it [here](http://microsoft.com/download/details.aspx?id=17718). 1. Make sure at least .NET Framework 4.5 is installed on your server computer. If not, [you can download it from Microsoft's website](http://microsoft.com/download/details.aspx?id=30653).
2. Download citimp_upd.exe from [here](https://github.com/icedream/citizenmp-server-updater/releases). The newest version is always at the top. Alternatively, you can also [get the latest build from the build server](http://builds.icedream.kthx.at/citiserver-updater-master/lastSuccessfulBuild/citimp_upd.exe), which is a little bit slower. 2. Make sure Microsoft Build Tools 2013 is installed on your server computer, [downloadable from Microsoft as well](http://microsoft.com/download/details.aspx?id=40760).
3. Create a new dedicated folder for citimp_upd.exe. It will later contain both your new server and the source code the tool downloads. Name it something like "CitizenMP" or similar. Move the file into the folder. 3. Download citimp_upd.exe from [here](https://github.com/icedream/citizenmp-server-updater/releases). The newest version is always at the top. Alternatively, you can also [get the latest build from the build server](http://builds.icedream.kthx.at/citiserver-updater-master/lastSuccessfulBuild/citimp_upd.exe), which is a little bit slower.
4. Inside the folder, create a new folder which will contain your server build. Name it something like "Server" or similar. 4. Create a new dedicated folder for citimp_upd.exe. It will later contain both your new server and the source code the tool downloads. Name it something like "CitizenMP" or similar. Move the file into the folder.
5. Drag and drop your newly created folder onto citimp_upd.exe. Wait for the tool to download, compile and prepare your server. The window should go away when done. 5. Inside the folder, create a new folder which will contain your server build. Name it something like "Server" or similar.
6. Now open your folder and like magic, some new files will be in there. Usually, you will now have to edit the configuration file before starting the server, so now would be a good time to do your custom changes. 6. Drag and drop your newly created folder onto citimp_upd.exe. Wait for the tool to download, compile and prepare your server. the window should go away when done.
7. When done, save any files you have open and start the server using the start.bat script that the tool generated for you. The server should display a new window and start up properly. 7. Now open your folder and like magic, some new files will be in there. Usually, you will now have to edit the configuration file before starting the server, so now would be a good time to do your custom changes.
8. When done, save any files you have open and start the server using the start.bat script that the tool generated for you. The server should display a new window and start up properly.

View File

@ -3,8 +3,8 @@ Server installation on Linux
On Linux, you should use a terminal (SSH connection/XTerm/...) to set up your server. On Linux, you should use a terminal (SSH connection/XTerm/...) to set up your server.
1. Make sure at least Mono 2.10.x is installed on your server computer. If not, you can install it using your distribution's package manager. For Debian/Ubuntu the command would normally be ```sudo apt-get install mono-runtime libmono-system-core4.0-cil```. 1. Make sure you have the newest Mono 3.x installed on your server computer (you can check the version using ```mono -V```). If not, [you should follow the official installation instructions](http://www.mono-project.com/docs/getting-started/install/linux/).
2. Download the latest citimp_upd.exe from [here](https://github.com/downloads/icedream/citizenmp-server-updater/citimp_upd.exe). You automate this using this command: ```wget https://github.com/icedream/citizenmp-server-updater/releases/download/v1.0.3/citimp_upd.exe``` 2. Download the latest citimp_upd.exe from [here](https://github.com/icedream/citizenmp-server-updater/releases/latest). If you are using SSH and want the file downloaded quickly or just generally want a direct download onto your server, this command should do: ```wget https://github.com/icedream/citizenmp-server-updater/releases/download/v1.1.0/citimp_upd.exe```
3. Create a new dedicated folder for citimp_upd.exe. It will later contain both your new server and the source code the tool downloads. Name it something like "CitizenMP" or similar. Move the file into the folder. Command for that would be ```mkdir CitizenMP``` 3. Create a new dedicated folder for citimp_upd.exe. It will later contain both your new server and the source code the tool downloads. Name it something like "CitizenMP" or similar. Move the file into the folder. Command for that would be ```mkdir CitizenMP```
4. Inside the folder, create a new folder which will contain your server build. Name it something like "Server" or similar. Command for this would be ```cd CitizenMP && mkdir Server``` 4. Inside the folder, create a new folder which will contain your server build. Name it something like "Server" or similar. Command for this would be ```cd CitizenMP && mkdir Server```
5. Run the tool and tell it to install files into your newly created folder. Command: ```mono citimp_upd.exe Server``` 5. Run the tool and tell it to install files into your newly created folder. Command: ```mono citimp_upd.exe Server```

View File

@ -1,6 +1,16 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <runtime>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> <generatePublisherEvidence enabled="false" />
</startup> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> </configuration>

View File

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<generatePublisherEvidence enabled="false" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CitizenMP.Server.Installer</RootNamespace> <RootNamespace>CitizenMP.Server.Installer</RootNamespace>
<AssemblyName>citizenmp_server_updater</AssemblyName> <AssemblyName>citizenmp_server_updater</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>95b7e825</NuGetPackageImportStamp> <NuGetPackageImportStamp>95b7e825</NuGetPackageImportStamp>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
@ -48,29 +48,21 @@
<StartupObject>CitizenMP.Server.Installer.Program</StartupObject> <StartupObject>CitizenMP.Server.Installer.Program</StartupObject>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="CommandLine, Version=1.9.71.2, Culture=neutral, PublicKeyToken=de6f01bd326f8c32, processorArchitecture=MSIL"> <Reference Include="CommandLine">
<SpecificVersion>False</SpecificVersion> <HintPath>$(SolutionDir)\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
<HintPath>$(SolutionDir)\packages\CommandLineParser.1.9.71\lib\net40\CommandLine.dll</HintPath>
</Reference> </Reference>
<Reference Include="Microsoft.Build" /> <Reference Include="Microsoft.Build, Version=12.0.0.0" />
<Reference Include="Microsoft.Build.Conversion.v4.0" /> <Reference Include="Microsoft.Build.Engine, Version=12.0.0.0" />
<Reference Include="Microsoft.Build.Engine" /> <Reference Include="Microsoft.Build.Framework, Version=12.0.0.0" />
<Reference Include="Microsoft.Build.Framework" />
<Reference Include="Microsoft.Build.Tasks.v4.0" />
<Reference Include="Microsoft.Build.Utilities.v4.0" />
<Reference Include="Mono.Posix"> <Reference Include="Mono.Posix">
<HintPath>$(SolutionDir)\packages\Mono.Posix.4.0.0.0\lib\net40\Mono.Posix.dll</HintPath> <HintPath>$(SolutionDir)\packages\Mono.Posix.4.0.0.0\lib\net40\Mono.Posix.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core" /> <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.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="CommandLineOptions.cs" /> <Compile Include="CommandLineOptions.cs" />
<Compile Include="Extensions.cs" />
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="RepositoryExtensions.cs" /> <Compile Include="RepositoryExtensions.cs" />
@ -97,6 +89,7 @@
<EmbeddedResource Include="costura64\git2-91fa31f.dll" /> <EmbeddedResource Include="costura64\git2-91fa31f.dll" />
<EmbeddedResource Include="costura32\*.so" /> <EmbeddedResource Include="costura32\*.so" />
<EmbeddedResource Include="costura64\*.so" /> <EmbeddedResource Include="costura64\*.so" />
<EmbeddedResource Include="AppDomainConfigurations\BuildNET45.xml" />
<Content Include="FodyWeavers.xml"> <Content Include="FodyWeavers.xml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Content> </Content>
@ -202,7 +195,6 @@ if [ ! -e "$(SolutionDir)src/updater/costura32"/git*.so ]; then
fi fi
</PreBuildEvent> </PreBuildEvent>
</PropertyGroup> </PropertyGroup>
<Import Project="$(SolutionDir)packages\Fody.1.26.1\build\Fody.targets" Condition="Exists('$(SolutionDir)packages\Fody.1.26.1\build\Fody.targets')" />
<Import Project="$(SolutionDir)packages\Fody.1.26.4\build\Fody.targets" Condition="Exists('..\..\packages\Fody.1.26.4\build\Fody.targets')" /> <Import Project="$(SolutionDir)packages\Fody.1.26.4\build\Fody.targets" Condition="Exists('..\..\packages\Fody.1.26.4\build\Fody.targets')" />
<Import Project="$(SolutionDir)packages\GitVersionTask.2.0.0\Build\GitVersionTask.targets" Condition="Exists('..\..\packages\GitVersionTask.2.0.0\Build\GitVersionTask.targets')" /> <Import Project="$(SolutionDir)packages\GitVersionTask.2.0.0\Build\GitVersionTask.targets" Condition="Exists('..\..\packages\GitVersionTask.2.0.0\Build\GitVersionTask.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.

14
src/updater/Extensions.cs Normal file
View File

@ -0,0 +1,14 @@
using System;
namespace CitizenMP.Server.Installer
{
internal static class Extensions
{
public static bool IsWin32(this OperatingSystem os)
{
return os.Platform == PlatformID.Win32NT ||
os.Platform == PlatformID.Win32S ||
os.Platform == PlatformID.Win32Windows;
}
}
}

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Weavers> <Weavers>
<Costura CreateTemporaryAssemblies="true" /> <Costura CreateTemporaryAssemblies="true"/>
</Weavers> </Weavers>

View File

@ -13,7 +13,6 @@ using Microsoft.Build.Evaluation;
using Microsoft.Build.Execution; using Microsoft.Build.Execution;
using Microsoft.Build.Framework; using Microsoft.Build.Framework;
using Mono.Unix.Native; using Mono.Unix.Native;
using Project = Microsoft.Build.BuildEngine.Project;
using UnixSyscall = Mono.Unix.Native.Syscall; using UnixSyscall = Mono.Unix.Native.Syscall;
namespace CitizenMP.Server.Installer namespace CitizenMP.Server.Installer
@ -59,6 +58,13 @@ namespace CitizenMP.Server.Installer
private static int Main(string[] args) private static int Main(string[] args)
{ {
var monoRun = RunWithMonoConfiguration(args);
if (monoRun.Item1)
{
// The main stuff already ran in a subprocess
return monoRun.Item2;
}
// Parse cmdline arguments // Parse cmdline arguments
var options = new CommandLineOptions(); var options = new CommandLineOptions();
//args = args.DefaultIfEmpty("--help").ToArray(); //args = args.DefaultIfEmpty("--help").ToArray();
@ -238,7 +244,7 @@ namespace CitizenMP.Server.Installer
{ {
{"Configuration", "Release"}, {"Configuration", "Release"},
{"Platform", "Any CPU"}, {"Platform", "Any CPU"},
{"DebugType", IsWin32() ? "None" : "pdbonly"}, {"DebugType", Environment.OSVersion.IsWin32() ? "None" : "pdbonly"},
{"DebugSymbols", false.ToString()}, {"DebugSymbols", false.ToString()},
{"OutputPath", binOutputDirectory.FullName}, {"OutputPath", binOutputDirectory.FullName},
{"AllowedReferenceRelatedFileExtensions", "\".mdb\"=\"\";\".pdb\"=\"\";\".xml\"=\"\""} {"AllowedReferenceRelatedFileExtensions", "\".mdb\"=\"\";\".pdb\"=\"\";\".xml\"=\"\""}
@ -315,6 +321,62 @@ namespace CitizenMP.Server.Installer
return 0; return 0;
} }
private static Tuple<bool, int> RunWithMonoConfiguration(string[] args)
{
if (Environment.OSVersion.IsWin32())
{
// .NET Framework does everything properly anyways
return new Tuple<bool, int>(false, 0);
}
var engineAssembly =
Assembly.Load(
"Microsoft.Build.Engine, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")
.GetName();
if (engineAssembly.Version.Major < 12)
{
//var baseDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var baseDir = Path.GetDirectoryName(Assembly.Load("CommandLine").Location);
if (baseDir == null)
throw new DirectoryNotFoundException("Could not find base directory");
var tempExePath = Path.Combine(baseDir, new Random().Next(10000, 99999) + ".exe");
File.Copy(Assembly.GetExecutingAssembly().Location, tempExePath);
var tempConfigPath = tempExePath + ".config";
using (var tempConfig = File.OpenWrite(tempConfigPath))
{
using (
var srcConfig =
Assembly.GetExecutingAssembly()
.GetManifestResourceStream(
"CitizenMP.Server.Installer.AppDomainConfigurations.BuildNET45.xml"))
{
if (srcConfig == null)
throw new FileNotFoundException("Could not find config resource");
srcConfig.CopyTo(tempConfig);
srcConfig.Flush();
}
}
AppDomain.CurrentDomain.DomainUnload += (sender, e) =>
{
File.Delete(tempConfigPath);
File.Delete(tempExePath);
};
var arguments = string.Join(" ",
new[] {tempExePath}.Concat(args)
.Select(a => "\"" + a.Replace("\\", "\\\\").Replace("\"", "\\\"") + "\""));
var exitCode = RunProcess("mono", arguments, new Dictionary<string, string>
{
{"MONO_IOMAP", "all"}
});
return new Tuple<bool, int>(true, exitCode);
}
return new Tuple<bool, int>(false, 0);
}
private static bool Build(string projectFilePath, IDictionary<string, string> buildProperties, private static bool Build(string projectFilePath, IDictionary<string, string> buildProperties,
LoggerVerbosity verbosity, string logPath = null) LoggerVerbosity verbosity, string logPath = null)
{ {
@ -349,7 +411,7 @@ namespace CitizenMP.Server.Installer
loggers.Add(new ConsoleLogger(verbosity) {ShowSummary = false}); loggers.Add(new ConsoleLogger(verbosity) {ShowSummary = false});
// Import/Update Mozilla certs for NuGet to not fail out on non-Windows machines // Import/Update Mozilla certs for NuGet to not fail out on non-Windows machines
if (!IsWin32()) if (!Environment.OSVersion.IsWin32())
{ {
try try
{ {
@ -357,15 +419,18 @@ namespace CitizenMP.Server.Installer
{ {
if (s == null || !s.Contains("X.509 Certificate")) if (s == null || !s.Contains("X.509 Certificate"))
return; return;
writer.WriteLine("y"); writer.WriteLine("yes");
}); });
// TODO: Make sure this does not fail out by checking if mozroots is installed // TODO: Make sure this does not fail out by checking if mozroots is installed
Console.WriteLine("Updating SSL certificates for NuGet..."); Console.WriteLine("Updating SSL certificates for NuGet...");
Run("mozroots", "--import --sync --quiet"); RunProcessThrowOnException("mozroots", "--import --sync --quiet");
Run("certmgr", "-ssl https://go.microsoft.com", automaticYesResponder); RunProcessThrowOnException("certmgr", "-ssl https://go.microsoft.com",
Run("certmgr", "-ssl https://nugetgallery.blob.core.windows.net", automaticYesResponder); lineProcessor: automaticYesResponder);
Run("certmgr", "-ssl https://nuget.org", automaticYesResponder); RunProcessThrowOnException("certmgr", "-ssl https://nugetgallery.blob.core.windows.net",
lineProcessor: automaticYesResponder);
RunProcessThrowOnException("certmgr", "-ssl https://nuget.org",
lineProcessor: automaticYesResponder);
} }
catch (Exception error) catch (Exception error)
{ {
@ -386,18 +451,27 @@ namespace CitizenMP.Server.Installer
} }
// Use a different build route if running on the Mono interpreter // Use a different build route if running on the Mono interpreter
if (!IsWin32()) if (!Environment.OSVersion.IsWin32())
{ {
// Build doesn't work with the new API on Mono, use the deprecated api
Console.WriteLine("Building server binaries..."); Console.WriteLine("Building server binaries...");
#pragma warning disable 618 #pragma warning disable 618
// Build doesn't work with the new API on Mono, use the deprecated api
var engine = Engine.GlobalEngine;
// loggers
foreach (var logger in loggers) foreach (var logger in loggers)
Engine.GlobalEngine.RegisterLogger(logger); engine.RegisterLogger(logger);
var project = new Project(Engine.GlobalEngine) {BuildEnabled = true};
project.Load(projectFilePath); // Apply build properties
var buildPropertiesConverted = new BuildPropertyGroup();
engine.GlobalProperties = buildPropertiesConverted;
foreach (var property in buildProperties) foreach (var property in buildProperties)
project.GlobalProperties.SetProperty(property.Key, property.Value); buildPropertiesConverted.SetProperty(property.Key, property.Value);
var result = project.Build();
// Load project
var result = engine.BuildProjectFile(projectFilePath, new string[0], null, null,
BuildSettings.None,
null);
#pragma warning restore 618 #pragma warning restore 618
return result; return result;
} }
@ -406,7 +480,8 @@ namespace CitizenMP.Server.Installer
{ {
Console.WriteLine("Building server binaries..."); Console.WriteLine("Building server binaries...");
var buildReq = new BuildRequestData(projectFilePath, buildProperties, null, new[] {"Build"}, null); var buildReq = new BuildRequestData(projectFilePath, buildProperties, null, new[] {"Build"},
null);
var result = BuildManager.DefaultBuildManager.Build( var result = BuildManager.DefaultBuildManager.Build(
new BuildParameters(pc) new BuildParameters(pc)
@ -424,18 +499,42 @@ namespace CitizenMP.Server.Installer
} }
} }
private static void Run(string name, string args, Action<string, StreamWriter> lineProcessor = null) private static void RunProcessThrowOnException(string name, string args,
IDictionary<string, string> envVars = null,
Action<string, StreamWriter> lineProcessor = null)
{ {
using (var p = Process.Start(new ProcessStartInfo var exitCode = RunProcess(name, args, envVars, lineProcessor);
if (exitCode != 0)
{
throw new Exception(string.Format("Process \"{0} {1}\" exited with error code {2}",
name, args, exitCode));
}
}
private static int RunProcess(string name, string args, IDictionary<string, string> envVars = null,
Action<string, StreamWriter> lineProcessor = null)
{
using (var p = new Process
{
StartInfo =
{ {
Arguments = args, Arguments = args,
FileName = name, FileName = name,
UseShellExecute = false, UseShellExecute = false,
CreateNoWindow = true, CreateNoWindow = true,
WorkingDirectory = Environment.CurrentDirectory,
RedirectStandardInput = lineProcessor != null, RedirectStandardInput = lineProcessor != null,
RedirectStandardOutput = lineProcessor != null RedirectStandardOutput = lineProcessor != null
})) }
})
{ {
if (envVars != null)
foreach (KeyValuePair<string, string> i in envVars)
p.StartInfo.EnvironmentVariables.Add(i.Key, i.Value);
p.Start();
if (lineProcessor == null) if (lineProcessor == null)
{ {
p.WaitForExit(); p.WaitForExit();
@ -449,19 +548,8 @@ namespace CitizenMP.Server.Installer
} }
} }
if (p.ExitCode != 0) return p.ExitCode;
{
throw new Exception(string.Format("Process \"{0} {1}\" exited with error code {2}",
name, args, p.ExitCode));
} }
} }
} }
private static bool IsWin32()
{
return Environment.OSVersion.Platform == PlatformID.Win32NT ||
Environment.OSVersion.Platform == PlatformID.Win32S ||
Environment.OSVersion.Platform == PlatformID.Win32Windows;
}
}
} }

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="CommandLineParser" version="1.9.71" targetFramework="net40" /> <package id="CommandLineParser" version="1.9.71" targetFramework="net45" />
<package id="Costura.Fody-Mono" version="1.3.3.5" targetFramework="net40" developmentDependency="true" /> <package id="Costura.Fody-Mono" version="1.3.3.5" targetFramework="net45" developmentDependency="true" />
<package id="Fody" version="1.26.4" targetFramework="net40" developmentDependency="true" /> <package id="Fody" version="1.26.4" targetFramework="net40" developmentDependency="true" />
<package id="GitVersionTask" version="2.0.0" targetFramework="net40" developmentDependency="true" /> <package id="GitVersionTask" version="2.0.0" targetFramework="net40" developmentDependency="true" />
<package id="Mono.Posix" version="4.0.0.0" targetFramework="net45" /> <package id="Mono.Posix" version="4.0.0.0" targetFramework="net45" />

View File

@ -1,6 +1,16 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<configuration> <configuration>
<startup> <runtime>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> <generatePublisherEvidence enabled="false" />
</startup> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Engine" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="12.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration> </configuration>

View File

@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CitizenMP.Server.Updater.Wrapper</RootNamespace> <RootNamespace>CitizenMP.Server.Updater.Wrapper</RootNamespace>
<AssemblyName>citimp_upd</AssemblyName> <AssemblyName>citimp_upd</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<TargetFrameworkProfile /> <TargetFrameworkProfile />
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir> <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
@ -95,8 +95,7 @@
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System" /> <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.IO" />
<Using xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Namespace="System.Xml.Linq" /> <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"> <Code xmlns="http://schemas.microsoft.com/developer/msbuild/2003" Type="Fragment" Language="cs"><![CDATA[
<![CDATA[
var config = XElement.Load(Config.ItemSpec).Elements("Costura").FirstOrDefault(); var config = XElement.Load(Config.ItemSpec).Elements("Costura").FirstOrDefault();
if (config == null) return true; if (config == null) return true;
@ -115,8 +114,8 @@ var filesToCleanup = Files.Select(f => f.ItemSpec).Where(f => !excludedAssemblie
foreach (var item in filesToCleanup) foreach (var item in filesToCleanup)
File.Delete(item); File.Delete(item);
]]> ]]></Code>
</Code></Task> </Task>
</UsingTask> </UsingTask>
<Target Name="CleanReferenceCopyLocalPaths" AfterTargets="AfterBuild;NonWinFodyTarget"> <Target Name="CleanReferenceCopyLocalPaths" AfterTargets="AfterBuild;NonWinFodyTarget">
<CosturaCleanup Config="FodyWeavers.xml" Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" /> <CosturaCleanup Config="FodyWeavers.xml" Files="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')" />

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Weavers> <Weavers>
<Costura/> <Costura CreateTemporaryAssemblies="true"/>
</Weavers> </Weavers>

View File

@ -1,10 +1,11 @@
using System.Linq; using System;
using System.IO;
using System.Reflection; using System.Reflection;
// ReSharper disable once CheckNamespace // ReSharper disable once CheckNamespace
internal class Program internal static class Program
{ {
private static void Main(string[] args) private static int Main(string[] args)
{ {
var mainAsm = Assembly.Load("citizenmp_server_updater"); var mainAsm = Assembly.Load("citizenmp_server_updater");
@ -12,7 +13,7 @@ internal class Program
.GetMethod("Attach") .GetMethod("Attach")
.Invoke(null, null); .Invoke(null, null);
mainAsm.GetType("CitizenMP.Server.Installer.Program") return (int) mainAsm.GetType("CitizenMP.Server.Installer.Program")
.GetMethod("Main", BindingFlags.NonPublic | BindingFlags.Static) .GetMethod("Main", BindingFlags.NonPublic | BindingFlags.Static)
.Invoke(null, new object[] {args}); .Invoke(null, new object[] {args});
} }