Skip to content

Commit

Permalink
Merge pull request #25 from cwensley/update-projects
Browse files Browse the repository at this point in the history
Update projects
  • Loading branch information
cwensley authored Nov 19, 2019
2 parents 56011d8 + 7287fe4 commit c34d79b
Show file tree
Hide file tree
Showing 53 changed files with 1,034 additions and 3,349 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
[submodule "Libraries/Mono.Nat"]
path = Libraries/Mono.Nat
url = https://github.com/cwensley/Mono.Nat.git
[submodule "Libraries/Eto"]
path = Libraries/Eto
url = https://github.com/picoe/Eto.git
[submodule "Libraries/lidgren"]
path = Libraries/lidgren
url = https://github.com/lidgren/lidgren-network-gen3.git
1 change: 0 additions & 1 deletion Libraries/Eto
Submodule Eto deleted from 229f85
17 changes: 17 additions & 0 deletions Source/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Company>Picoe Software Solutions</Company>
<Copyright>(c) 2006-2019 by Curtis Wensley aka Eto</Copyright>
<Version>3.3.0-dev</Version>

<BasePath>$(MSBuildThisFileDirectory)..\</BasePath>
<ArtifactsDir>$(BasePath)Artifacts\</ArtifactsDir>

<BaseIntermediateOutputPath Condition="$(BaseIntermediateOutputPath) == ''">$(ArtifactsDir)obj\$(OS)\$(MSBuildProjectName)\</BaseIntermediateOutputPath>
<OutputArtifactName Condition="$(OutputArtifactName) == ''">bin</OutputArtifactName>
<BaseOutputPath Condition="$(BaseOutputPath) == ''">$(ArtifactsDir)$(OutputArtifactName)\</BaseOutputPath>
<PackageOutputPath Condition="$(PackageOutputPath) == ''">$(ArtifactsDir)nuget\$(Configuration)\</PackageOutputPath>
<RestoreProjectStyle Condition="'$(RestoreProjectStyle)' == ''">PackageReference</RestoreProjectStyle>

</PropertyGroup>
</Project>
49 changes: 49 additions & 0 deletions Source/Directory.Build.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<Import Project="EmbedReferences.targets" />

<UsingTask TaskName="_ParseVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
<ParameterGroup>
<Version ParameterType="System.String" Required="true" />
<AssemblyVersion ParameterType="System.String" Output="true" />
<AssemblyFileVersion ParameterType="System.String" Output="true" />
<AssemblyInformationalVersion ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System"/>
<Using Namespace="System.IO"/>
<Using Namespace="System.Text.RegularExpressions"/>
<Code Type="Fragment" Language="cs"><![CDATA[
var regex = new Regex(@"(?<ver>(?<maj>\d+)[.](?<min>\d+)([.](?<build>\d+)([.](?<rev>\d+))?)?)([-](?<info>.+))?");
if (string.IsNullOrEmpty(AssemblyVersion)) AssemblyVersion = regex.Replace(Version, "${ver}");
if (string.IsNullOrEmpty(AssemblyFileVersion)) AssemblyFileVersion = AssemblyFileVersion ?? regex.Replace(Version, "${ver}");
if (string.IsNullOrEmpty(AssemblyInformationalVersion)) AssemblyInformationalVersion = Version;
]]></Code>
</Task>
</UsingTask>

<Target Name="_ParseAssemblyVersion" BeforeTargets="BeforeBuild">

<_ParseVersion Version="$(Version)">
<Output TaskParameter="AssemblyVersion" PropertyName="AssemblyVersion"/>
<Output TaskParameter="AssemblyFileVersion" PropertyName="AssemblyFileVersion"/>
<Output TaskParameter="AssemblyInformationalVersion" PropertyName="AssemblyInformationalVersion"/>
</_ParseVersion>
</Target>

<Target Name="_WriteVersion" BeforeTargets="CoreCompile" Condition="$(GenerateAssemblyVersion) == 'True'"
Inputs="$(MSBuildAllProjects);@(Compile);@(_CoreCompileResourceInputs);$(ApplicationIcon);$(AssemblyOriginatorKeyFile);@(ReferencePathWithRefAssemblies);@(CompiledLicenseFile);@(LinkResource);@(EmbeddedDocumentation);$(Win32Resource);$(Win32Manifest);@(CustomAdditionalCompileInputs);$(ResolvedCodeAnalysisRuleSet);@(AdditionalFiles);@(EmbeddedFiles)"
Outputs="$(IntermediateOutputPath)VersionInfo.cs">

<ItemGroup>
<VersionInfo Include="[assembly: System.Reflection.AssemblyVersion(&quot;$(AssemblyVersion)&quot;)]" />
<VersionInfo Include="[assembly: System.Reflection.AssemblyFileVersion(&quot;$(AssemblyFileVersion)&quot;)]" />
<VersionInfo Include="[assembly: System.Reflection.AssemblyInformationalVersion(&quot;$(AssemblyInformationalVersion)&quot;)]" />
</ItemGroup>
<MakeDir Directories="$(IntermediateOutputPath)" />
<WriteLinesToFile File="$(IntermediateOutputPath)VersionInfo.cs" Overwrite="True" Lines="@(VersionInfo)" />
</Target>

</Project>
148 changes: 148 additions & 0 deletions Source/EmbedReferences.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<!--
Embeds references inside a single assembly.
-->
<PropertyGroup>
<ShouldEmbed Condition="$(OutputType) == 'Library' OR $(OutputType) == 'Exe' OR $(OutputType) == 'WinExe'">True</ShouldEmbed>
</PropertyGroup>

<Target Name="_EmbedReferencedAssemblies" Condition="$(ShouldEmbed) == 'True' AND $(EmbedReferences) != ''" AfterTargets="ResolveAssemblyReferences">
<PropertyGroup>
<EmbedDebugSymbols Condition="$(EmbedDebugSymbols) == ''">false</EmbedDebugSymbols>
<EmbedPrefix Condition="$(EmbedPrefix) == ''">References</EmbedPrefix>
<EmbedCopyLocalReferences Condition="$(EmbedCopyLocalReferences) == ''">False</EmbedCopyLocalReferences>
</PropertyGroup>
<!-- Embed only specified references -->
<_GetCommonFiles Files="@(ReferencePath)" Names="$(EmbedReferences)" Condition="$(EmbedReferences) != 'True'">
<Output ItemName="EmbedReferences" TaskParameter="Result" />
</_GetCommonFiles>
<ItemGroup>
<EmbedExcludeReferences Include="$(EmbedExcludeReferences)"/>

<!-- Embed all copy local references -->
<EmbedReferences Include="@(ReferenceCopyLocalPaths)" Condition="$(EmbedReferences) == 'True'" />
<EmbedReferences Remove="@(ReferenceCopyLocalPaths)" Condition="'%(FileName)%(Extension)' == @(EmbedExcludeReferences->'%(Identity)')"/>
<!-- Find files to embed and exclude -->
<FilesToEmbed Include="@(EmbedReferences)" Condition="'%(EmbedReferences.Extension)' == '.dll'" />
<FilesToEmbed Include="@(EmbedReferences)" Condition="$(EmbedDebugSymbols) == 'True' AND '%(EmbedReferences.Extension)' == '.pdb'" />
<FilesToExclude Include="@(EmbedReferences)" Condition="$(EmbedDebugSymbols) != 'True' AND '%(EmbedReferences.Extension)' == '.pdb'" />
<FilesToExclude Include="@(EmbedReferences)" Condition="'%(EmbedReferences.Extension)' == '.xml'" />
<EmbeddedResource Include="@(FilesToEmbed)">
<LogicalName>$(EmbedPrefix).%(FilesToEmbed.DestinationSubDirectory)%(FilesToEmbed.Filename)%(FilesToEmbed.Extension)</LogicalName>
</EmbeddedResource>
<!-- no need to copy the assemblies locally anymore -->
<ReferenceCopyLocalPaths Remove="@(FilesToEmbed)" Condition="$(EmbedCopyLocalReferences) != 'True'" />
<ReferenceCopyLocalPaths Remove="@(FilesToExclude)" Condition="$(EmbedCopyLocalReferences) != 'True'" />
</ItemGroup>
<Message Importance="high" Text="Embedding: @(FilesToEmbed->'%(Filename)%(Extension)', ', ')" />
</Target>

<ItemGroup Condition="$(ShouldEmbed) == 'True'">
<Compile Include="$(IntermediateOutputPath)EmbedReferences.cs">
<Link>EmbedReferences.cs</Link>
<Visible>false</Visible>
</Compile>
</ItemGroup>
<Target Name="_WriteEmbedReferences"
Condition="$(ShouldEmbed) == 'True'"
BeforeTargets="CoreCompile"
Outputs="$(IntermediateOutputPath)EmbedReferences.cs">
<PropertyGroup>
<EmbedReferencesLines>
<![CDATA[using System%3b
using System.Collections.Generic%3b
using System.IO%3b
using System.Reflection%3b
/// <summary>
/// Loads assemblies from embedded resources instead of from disk
/// </summary>
/// <remarks>
/// This is useful when you want to create a single assembly/executable without having to ship referenced dll's
/// alongside your application.
/// </remarks>
/// <copyright>(c) 2012 by Curtis Wensley</copyright>
/// <license type="BSD-3">See LICENSE for full terms</license>
class EmbedReferences
{
readonly Dictionary<string, Assembly> loadedAssemblies = new Dictionary<string, Assembly>()%3b
/// <summary>
/// Gets the assembly in which this loader will load assembly resources from
/// </summary>
public Assembly Assembly { get%3b private set%3b }
/// <summary>
/// Gets the namespace in the <see cref="Assembly"/> to get the assembly resources from
/// </summary>
public string ResourceNamespace { get%3b private set%3b }
/// <summary>
/// Registers the specified namespace for loading embedded assemblies
/// </summary>
/// <param name="resourceNamespace">Namespace of where the embedded assemblies should be loaded</param>
/// <param name="assembly">Assembly to load the embedded assemblies from, or null to use the calling assembly</param>
/// <param name="domain">Application domain to load the assemblies in, or null to use the current app domain</param>
/// <returns>A new instance of an EmbedReferences, registered for the specified namespace and assembly</returns>
public static EmbedReferences Init(string resourceNamespace = "References", Assembly assembly = null, AppDomain domain = null)
{
assembly = assembly ?? Assembly.GetCallingAssembly()%3b
var loader = new EmbedReferences(resourceNamespace, assembly)%3b
loader.Init(domain)%3b
return loader%3b
}
/// <summary>
/// Initializes a new instance of the EmbedReferences
/// </summary>
/// <param name="resourceNamespace">Namespace of where the embedded assemblies should be loaded</param>
/// <param name="assembly">Assembly to load the embedded assemblies from, or null to use the calling assembly</param>
public EmbedReferences(string resourceNamespace, Assembly assembly = null)
{
this.Assembly = assembly ?? Assembly.GetCallingAssembly()%3b
this.ResourceNamespace = resourceNamespace%3b
}
/// <summary>
/// Registers this loader for the specified <paramref name="domain"/>
/// </summary>
/// <param name="domain">App domain to register this loader for, or null to use the current domain</param>
public void Init(AppDomain domain = null)
{
domain = domain ?? AppDomain.CurrentDomain%3b
domain.AssemblyResolve += (sender, args) =>
{
var assemblyName = new AssemblyName(args.Name)%3b
if (assemblyName.Name.EndsWith(".resources", StringComparison.OrdinalIgnoreCase)) return null%3b
string resourceName = ResourceNamespace + "." + assemblyName.Name + ".dll"%3b
Assembly loadedAssembly%3b
lock (loadedAssemblies)
{
if (!loadedAssemblies.TryGetValue(resourceName, out loadedAssembly))
{
using (var stream = Assembly.GetManifestResourceStream(resourceName))
{
if (stream != null)
{
using (var binaryReader = new BinaryReader(stream))
{
loadedAssembly = Assembly.Load(binaryReader.ReadBytes((int)stream.Length))%3b
loadedAssemblies.Add(resourceName, loadedAssembly)%3b
}
}
}
}
}
return loadedAssembly%3b
}%3b
}
}
]]></EmbedReferencesLines>
</PropertyGroup>
<MakeDir Directories="$(IntermediateOutputPath)" />
<WriteLinesToFile File="$(IntermediateOutputPath)EmbedReferences.cs" Overwrite="True" Lines="$(EmbedReferencesLines)" />
</Target>

</Project>
11 changes: 0 additions & 11 deletions Source/GlobalAssemblyInfo.cs

This file was deleted.

Loading

0 comments on commit c34d79b

Please sign in to comment.