restructure template project generation

main
cosmonaut 2022-01-25 16:25:44 -08:00
parent 4fee6459fc
commit 64c59fa434
16 changed files with 66 additions and 613 deletions

26
.vscode/launch.json vendored
View File

@ -1,36 +1,14 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Framework Debugger",
"type": "clr",
"request": "launch",
"preLaunchTask": "Build: Framework Debug",
"program": "${workspaceFolder}/ProjectName/bin/x64/Debug/net472/ProjectName.exe",
"args": [],
"cwd": "${workspaceFolder}/ProjectName/bin/x64/Debug/net472",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "Attach to Mono Debugger",
"type": "mono",
"request": "launch",
"preLaunchTask": "Build: Mono Debug",
"program": "${workspaceFolder}/ProjectName/bin/x64/Debug/net472/ProjectName.exe",
"args": [],
"cwd": "${workspaceFolder}/ProjectName/bin/x64/Debug/net472",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
},
{
"name": "Attach to .NET 5 Debugger",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "Build: .NET 5 Debug",
"program": "${workspaceFolder}/ProjectName/bin/x64/Debug/net5.0/ProjectName.dll",
"program": "${workspaceFolder}/bin/x64/Debug/net5.0/ProjectName.dll",
"args": [],
"cwd": "${workspaceFolder}/ProjectName/bin/x64/Debug/net5.0",
"cwd": "${workspaceFolder}/bin/x64/Debug/net5.0",
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}

194
.vscode/tasks.json vendored
View File

@ -20,106 +20,6 @@
"panel": "shared"
},
"tasks": [
{
"label": "Build: Mono Release",
"command": "msbuild",
"args": [
"-restore:True",
"${workspaceFolder}/ProjectName.Framework.sln",
"-p:Configuration=Release",
"-p:Platform=x64"
],
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": "$msCompile"
},
{
"label": "Run: Mono Release",
"command": "mono",
"args": [
"ProjectName.exe"
],
"options": {
"env": {
"LD_LIBRARY_PATH": "./lib64",
"DYLD_LIBRARY_PATH": "./osx"
},
"cwd": "${workspaceFolder}/ProjectName/bin/x64/Release/net472"
},
"type": "process",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build & Run: Mono Release",
"dependsOn": [
"Build: Mono Release",
"Run: Mono Release"
],
"dependsOrder": "sequence",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build: Mono Debug",
"command": "msbuild",
"args": [
"-restore:True",
"${workspaceFolder}/ProjectName.Framework.sln",
"-p:Configuration=Debug",
"-p:Platform=x64"
],
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Run: Mono Debug",
"command": "mono",
"args": [
"ProjectName.exe"
],
"options": {
"env": {
"LD_LIBRARY_PATH": "./lib64",
"DYLD_LIBRARY_PATH": "./osx"
},
"cwd": "${workspaceFolder}/ProjectName/bin/x64/Debug/net472"
},
"type": "process",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build & Run: Mono Debug",
"dependsOn": [
"Build: Mono Debug",
"Run: Mono Debug"
],
"dependsOrder": "sequence",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build & Run: .NET 5 Debug",
"type": "shell",
@ -139,7 +39,7 @@
"command": "dotnet",
"args": [
"build",
"./ProjectName/ProjectName.Core.csproj",
"./ProjectName.csproj",
"-p:SolutionDir=${workspaceFolder}/",
"-p:Platform=x64"
],
@ -161,7 +61,7 @@
"LD_LIBRARY_PATH": "./lib64",
"DYLD_LIBRARY_PATH": "./osx"
},
"cwd": "${workspaceFolder}/ProjectName/bin/x64/Debug/net5.0"
"cwd": "${workspaceFolder}/bin/x64/Debug/net5.0"
},
"type": "process",
"group": {
@ -175,7 +75,7 @@
"command": "dotnet",
"args": [
"build",
"./ProjectName/ProjectName.Core.csproj",
"./ProjectName.csproj",
"--configuration",
"Release",
"-p:SolutionDir=${workspaceFolder}/",
@ -199,7 +99,7 @@
"LD_LIBRARY_PATH": "./lib64",
"DYLD_LIBRARY_PATH": "./osx"
},
"cwd": "${workspaceFolder}/ProjectName/bin/x64/Release/net5.0"
"cwd": "${workspaceFolder}/bin/x64/Release/net5.0"
},
"type": "process",
"group": {
@ -221,92 +121,6 @@
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build: Framework Debug",
"command": "MsBuild.exe",
"args": [
"-restore:True",
"${workspaceFolder}/ProjectName.Framework.sln",
"-p:Configuration=Debug",
"-p:Platform=x64"
],
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Run: Framework Debug",
"command": "ProjectName.exe",
"options": {
"cwd": "${workspaceFolder}/ProjectName/bin/x64/Debug/net472"
},
"type": "process",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build & Run: Framework Debug",
"dependsOn": [
"Build: Framework Debug",
"Run: Framework Debug"
],
"dependsOrder": "sequence",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build: Framework Release",
"command": "MsBuild.exe",
"args": [
"-restore:True",
"${workspaceFolder}/ProjectName.Framework.sln",
"-p:Configuration=Release",
"-p:Platform=x64"
],
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Run: Framework Release",
"command": "ProjectName.exe",
"options": {
"cwd": "${workspaceFolder}/ProjectName/bin/x64/Release/net472"
},
"type": "process",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build & Run: Framework Release",
"dependsOn": [
"Build: Framework Release",
"Run: Framework Release"
],
"dependsOrder": "sequence",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
}
]
}

View File

@ -5,26 +5,26 @@
<Message Text="Runtime ID: $(RuntimeIdentifier)" Importance="high"/>
</Target>
<ItemGroup Condition="$(RuntimeIdentifier.Contains('win'))">
<Content Include="..\moonlibs\windows\FAudio.dll">
<ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Windows)))">
<Content Include=".\moonlibs\windows\FAudio.dll">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\moonlibs\windows\Refresh.dll">
<Content Include=".\moonlibs\windows\Refresh.dll">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\moonlibs\windows\SDL2.dll">
<Content Include=".\moonlibs\windows\SDL2.dll">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition="('$(RuntimeIdentifier)' == '' AND $([MSBuild]::IsOSPlatform('Linux'))) OR $(RuntimeIdentifier.Contains('linux'))">
<Content Include="..\moonlibs\lib64\libFAudio.*">
<ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))">
<Content Include=".\moonlibs\lib64\libFAudio.*">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="..\moonlibs\lib64\libRefresh.*">
<Content Include=".\moonlibs\lib64\libRefresh.*">
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
@ -33,8 +33,8 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup Condition="$(RuntimeIdentifier.Contains('osx'))">
<Content Include="..\moonlibs\osx\**\*.*" >
<ItemGroup Condition="$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))">
<Content Include=".\moonlibs\osx\**\*.*" >
<Link>%(RecursiveDir)%(Filename)%(Extension)</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>

View File

@ -1,31 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30717.126
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectName.Framework", "ProjectName\ProjectName.Framework.csproj", "{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Debug|x64.ActiveCfg = Debug|x64
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Debug|x64.Build.0 = Debug|x64
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Debug|x86.ActiveCfg = Debug|x86
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Debug|x86.Build.0 = Debug|x86
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Release|x64.ActiveCfg = Release|x64
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Release|x64.Build.0 = Release|x64
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Release|x86.ActiveCfg = Release|x86
{9ED076FA-32C3-4F1E-BB90-549B3A2FA46F}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4DB7BE1E-CAC6-4275-B514-20CBE80F794F}
EndGlobalSection
EndGlobal

View File

@ -1,11 +1,12 @@
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath>obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<Platforms>x64;x86</Platforms>
</PropertyGroup>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<TargetName>ProjectName</TargetName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
@ -15,17 +16,22 @@
<AssemblyName>ProjectName</AssemblyName>
<RootNamespace>ProjectName</RootNamespace>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplicationIcon />
</PropertyGroup>
<ItemGroup>
<Content Include="Content\**\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);lib\**\*</DefaultItemExcludes>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\lib\MoonWorks\MoonWorks.csproj" />
<ProjectReference Include="lib\MoonWorks\MoonWorks.csproj" />
</ItemGroup>
<Import Project=".\CopyMoonlibs.targets" />
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
</Project>

View File

@ -1,31 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30717.126
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectName.Core", "ProjectName\ProjectName.Core.csproj", "{4589302C-174A-4173-9654-CAA6CA1B5220}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4589302C-174A-4173-9654-CAA6CA1B5220}.Debug|x64.ActiveCfg = Debug|x64
{4589302C-174A-4173-9654-CAA6CA1B5220}.Debug|x64.Build.0 = Debug|x64
{4589302C-174A-4173-9654-CAA6CA1B5220}.Debug|x86.ActiveCfg = Debug|x86
{4589302C-174A-4173-9654-CAA6CA1B5220}.Debug|x86.Build.0 = Debug|x86
{4589302C-174A-4173-9654-CAA6CA1B5220}.Release|x64.ActiveCfg = Release|x64
{4589302C-174A-4173-9654-CAA6CA1B5220}.Release|x64.Build.0 = Release|x64
{4589302C-174A-4173-9654-CAA6CA1B5220}.Release|x86.ActiveCfg = Release|x86
{4589302C-174A-4173-9654-CAA6CA1B5220}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {70247DA8-9C19-4FC5-B4BC-68E1262B9F4B}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30717.126
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectName.Core", "ProjectName\ProjectName.Core.csproj", "{4589302C-174A-4173-9654-CAA6CA1B5220}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4589302C-174A-4173-9654-CAA6CA1B5220}.Debug|x64.ActiveCfg = Debug|x64
{4589302C-174A-4173-9654-CAA6CA1B5220}.Debug|x64.Build.0 = Debug|x64
{4589302C-174A-4173-9654-CAA6CA1B5220}.Release|x64.ActiveCfg = Release|x64
{4589302C-174A-4173-9654-CAA6CA1B5220}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {70247DA8-9C19-4FC5-B4BC-68E1262B9F4B}
EndGlobalSection
EndGlobal

View File

@ -1,259 +0,0 @@
// only works in .NET Core. disable in .NET framework
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Xml.Linq;
public static class DllMap
{
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetDefaultDllDirectories(int directoryFlags);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern void AddDllDirectory(string lpPathName);
[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool SetDllDirectory(string lpPathName);
const int LOAD_LIBRARY_SEARCH_DEFAULT_DIRS = 0x00001000;
public static Dictionary<string, string> MapDictionary;
public static string OS;
public static string CPU;
public static bool Optimise;
public static void Initialise(bool optimise = true)
{
Optimise = optimise;
// Our executabe needs to know how to find the native libraries
// For Windows, we can set this to be x86 or x64 directory at runtime (below)
// For Linux we need to move our native libraries to 'netcoredeps' which is set by .net core
// For OSX we need to set an environment variable (DYLD_LIBRARY_PATH) outside of the process by a script
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
try
{
SetDefaultDllDirectories(LOAD_LIBRARY_SEARCH_DEFAULT_DIRS);
AddDllDirectory(Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
Environment.Is64BitProcess ? "x64" : "x86"
));
}
catch
{
// Pre-Windows 7, KB2533623
SetDllDirectory(Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
Environment.Is64BitProcess ? "x64" : "x86"
));
}
}
// .NET Core also doesn't use DllImport but we can replicate this using NativeLibrary as per below
// Uses MoonWorks.dll.config to dictate what the name of the native library is per platform and architecture
var moonWorksAssembly = Assembly.GetAssembly(typeof(Microsoft.Xna.Framework.Graphics.ColorWriteChannels));
DllMap.Register(moonWorksAssembly);
}
// Register a call-back for native library resolution.
public static void Register(Assembly assembly)
{
NativeLibrary.SetDllImportResolver(assembly, MapAndLoad);
// Do setup so that MapLibraryName is faster than reading the XML each time
// 1) Get platform & cpu
OS = GetCurrentPlatform().ToString().ToLowerInvariant();
CPU = GetCurrentRuntimeArchitecture().ToString().ToLowerInvariant();
// 2) Setup MapDictionary
// For Windows use hardcoded values
// Why? This is our development platform and we wanted the fastest start time possible (eliminates XML Load)
if (OS == "windows" && Optimise)
{
MapDictionary = new Dictionary<string, string>();
MapDictionary.Add("SDL2", "SDL2.dll");
MapDictionary.Add("Refresh", "Refresh.dll");
MapDictionary.Add("FAudio", "FAudio.dll");
}
else
{
// For every other platform use XML file
// Read in config XML and only store details we're interested in within MapDictionary
string xmlPath = Path.Combine(Path.GetDirectoryName(assembly.Location),
Path.GetFileNameWithoutExtension(assembly.Location) + ".dll.config");
if (!File.Exists(xmlPath))
{
Console.WriteLine($"=== Cannot find XML: " + xmlPath);
return;
}
XElement root = XElement.Load(xmlPath);
MapDictionary = new Dictionary<string, string>();
ParseXml(root, true); // Direct match on OS & CPU first
ParseXml(root, false); // Loose match on CPU second (won't allow duplicates)
}
}
private static void ParseXml(XElement root, bool matchCPU)
{
foreach (var el in root.Elements("dllmap"))
{
// Ignore entries for other OSs
if (el.Attribute("os").ToString().IndexOf(OS) < 0)
continue;
// Ignore entries for other CPUs
if (matchCPU)
{
if (el.Attribute("cpu") == null)
continue;
if (el.Attribute("cpu").ToString().IndexOf(CPU) < 0)
continue;
}
else
{
if (el.Attribute("cpu") != null && el.Attribute("cpu").ToString().IndexOf(CPU) < 0)
continue;
}
string oldLib = el.Attribute("dll").Value;
string newLib = el.Attribute("target").Value;
if (string.IsNullOrWhiteSpace(oldLib) || string.IsNullOrWhiteSpace(newLib))
continue;
// Don't allow duplicates
if (MapDictionary.ContainsKey(oldLib))
continue;
MapDictionary.Add(oldLib, newLib);
}
}
// The callback: which loads the mapped libray in place of the original
private static IntPtr MapAndLoad(string libraryName, Assembly assembly, DllImportSearchPath? dllImportSearchPath)
{
string mappedName = null;
mappedName = MapLibraryName(assembly.Location, libraryName, out mappedName) ? mappedName : libraryName;
return NativeLibrary.Load(mappedName, assembly, dllImportSearchPath);
}
// Parse the assembly.xml file, and map the old name to the new name of a library.
private static bool MapLibraryName(string assemblyLocation, string originalLibName, out string mappedLibName)
{
if (MapDictionary.TryGetValue(originalLibName, out mappedLibName))
return true;
else
return false;
}
// Below pinched from Mono.DllMap project: https://github.com/Firwood-Software/AdvancedDLSupport/tree/1b7394211a655b2f77649ce3b610a3161215cbdc/Mono.DllMap
public static DllMapOS GetCurrentPlatform()
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
return DllMapOS.Linux;
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
return DllMapOS.Windows;
}
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
return DllMapOS.OSX;
}
var operatingDesc = RuntimeInformation.OSDescription.ToUpperInvariant();
foreach (var system in Enum.GetValues(typeof(DllMapOS)).Cast<DllMapOS>()
.Except(new[] { DllMapOS.Linux, DllMapOS.Windows, DllMapOS.OSX }))
{
if (operatingDesc.Contains(system.ToString().ToUpperInvariant()))
{
return system;
}
}
throw new PlatformNotSupportedException($"Couldn't detect platform: {RuntimeInformation.OSDescription}");
}
public static DllMapArchitecture GetCurrentRuntimeArchitecture()
{
switch (RuntimeInformation.ProcessArchitecture)
{
case Architecture.Arm:
{
return DllMapArchitecture.ARM;
}
case Architecture.X64:
{
return DllMapArchitecture.x86_64;
}
case Architecture.X86:
{
return DllMapArchitecture.x86;
}
}
typeof(object).Module.GetPEKind(out _, out var machine);
switch (machine)
{
case ImageFileMachine.I386:
{
return DllMapArchitecture.x86;
}
case ImageFileMachine.AMD64:
{
return DllMapArchitecture.x86_64;
}
case ImageFileMachine.ARM:
{
return DllMapArchitecture.ARM;
}
case ImageFileMachine.IA64:
{
return DllMapArchitecture.IA64;
}
}
throw new PlatformNotSupportedException("Couldn't detect the current architecture.");
}
public enum DllMapOS
{
Linux = 1 << 0,
OSX = 1 << 1,
Solaris = 1 << 2,
FreeBSD = 1 << 3,
OpenBSD = 1 << 4,
NetBSD = 1 << 5,
Windows = 1 << 6,
AIX = 1 << 7,
HPUX = 1 << 8
}
public enum DllMapArchitecture
{
x86 = 1 << 0,
x86_64 = 1 << 1,
SPARC = 1 << 2,
PPC = 1 << 3,
S390 = 1 << 4,
S390X = 1 << 5,
ARM = 1 << 6,
ARMV8 = 1 << 7,
MIPS = 1 << 8,
Alpha = 1 << 9,
HPPA = 1 << 10,
IA64 = 1 << 11
}
}

View File

@ -1,34 +0,0 @@
<Project>
<PropertyGroup>
<BaseIntermediateOutputPath>obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<Platforms>x64;x86</Platforms>
</PropertyGroup>
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.props" />
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net472</TargetFramework>
<TargetName>ProjectName</TargetName>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<LangVersion>8.0</LangVersion>
<StartupObject>ProjectName.Program</StartupObject>
<AssemblyName>ProjectName</AssemblyName>
<RootNamespace>ProjectName</RootNamespace>
<TargetLatestRuntimePatch>true</TargetLatestRuntimePatch>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplicationIcon />
</PropertyGroup>
<PropertyGroup>
<DefaultItemExcludes>$(DefaultItemExcludes);DllMap.cs</DefaultItemExcludes>
</PropertyGroup>
<ItemGroup>
<Content Include="Content\**\*.*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\lib\MoonWorks\MoonWorks.csproj" />
</ItemGroup>
<Import Project=".\CopyMoonlibs.targets" />
<Import Sdk="Microsoft.NET.Sdk" Project="Sdk.targets" />
</Project>

View File

@ -84,7 +84,7 @@ fi
cp -R "$MY_DIR" "$NEW_PROJECT_DIR"
cd "$NEW_PROJECT_DIR"
files=(ProjectName.Core.sln ProjectName.Framework.sln .gitignore ProjectName/ProjectName.Core.csproj ProjectName/ProjectName.Framework.csproj ProjectName/ProjectNameGame.cs ProjectName/Program.cs ProjectName/Graphics/GraphicsObjects.cs ProjectName/Graphics/Containers/Framebuffers.cs ProjectName/Graphics/Containers/RenderPasses.cs ProjectName/Graphics/Containers/RenderTargets.cs .vscode/tasks.json .vscode/launch.json)
files=(ProjectName.sln .gitignore ProjectName.csproj src/ProjectNameGame.cs src/Program.cs src/Graphics/GraphicsObjects.cs src/Graphics/Containers/Framebuffers.cs src/Graphics/Containers/RenderPasses.cs src/Graphics/Containers/RenderTargets.cs .vscode/tasks.json .vscode/launch.json)
for file in "${files[@]}"; do
sed -i -e "s/ProjectName/$newProjectName/g" "./$file"
if [ "$(uname)" == "Darwin" ]; then
@ -92,23 +92,20 @@ for file in "${files[@]}"; do
fi
done
mv ./ProjectName.Core.sln "./$newProjectName.Core.sln"
mv ./ProjectName.Framework.sln "./$newProjectName.Framework.sln"
mv ./ProjectName/ProjectName.Core.csproj "./ProjectName/$newProjectName.Core.csproj"
mv ./ProjectName/ProjectName.Framework.csproj "./ProjectName/$newProjectName.Framework.csproj"
mv ./ProjectName/ProjectNameGame.cs ./ProjectName/${newProjectName}Game.cs
mv ./ProjectName "./$newProjectName"
mv ./ProjectName.sln "./$newProjectName.sln"
mv ./ProjectName.csproj "./$newProjectName.csproj"
mv ./src/ProjectNameGame.cs ./src/${newProjectName}Game.cs
rm ./install.sh
rm ./LICENSE
rm -rf .git
git init
git branch -m main
git checkout -b main
git branch -D master
mkdir lib
pullMoonWorks
dotnet sln ${newProjectName}.Framework.sln add lib/MoonWorks/MoonWorks.csproj
dotnet sln ${newProjectName}.Core.sln add lib/MoonWorks/MoonWorks.csproj
dotnet sln ${newProjectName}.sln add lib/MoonWorks/MoonWorks.csproj
echo "Project $newProjectName created at: "

View File

@ -15,18 +15,6 @@ namespace ProjectName
static void Main(string[] args)
{
#if NETCOREAPP
DllMap.Initialise(false);
#endif
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
SetDllDirectory(Path.Combine(
AppDomain.CurrentDomain.BaseDirectory,
Environment.Is64BitProcess ? "x64" : "x86"
));
}
WindowCreateInfo windowCreateInfo = new WindowCreateInfo
{
WindowWidth = 1280,
@ -44,4 +32,4 @@ namespace ProjectName
game.Run();
}
}
}
}

View File

@ -28,12 +28,12 @@ namespace ProjectName
RenderHeight = (int)windowCreateInfo.WindowHeight;
}
protected override void Update(double dt)
protected override void Update(System.TimeSpan dt)
{
// Insert your game update logic here.
}
protected override void Draw(double dt, double alpha)
protected override void Draw(System.TimeSpan dt, double alpha)
{
// Replace this with your own drawing code.