diff --git a/P3D.sln b/P3D.sln index 141663bfd..dc10089e4 100644 --- a/P3D.sln +++ b/P3D.sln @@ -13,6 +13,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Kolben", "lib\kolben\Kolben EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{7877D883-AA51-4C27-ADA5-C4F85F86F4EE}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PostBuild", "lib\tools\PostBuild\PostBuild.csproj", "{3B2AEA8E-4384-48D8-B26B-2C67466A1352}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +47,14 @@ Global {ED665F9B-07F4-4415-BD72-A728CF1EA909}.Release|Any CPU.Build.0 = Release|Any CPU {ED665F9B-07F4-4415-BD72-A728CF1EA909}.ReleaseNoContent|Any CPU.ActiveCfg = Release|Any CPU {ED665F9B-07F4-4415-BD72-A728CF1EA909}.ReleaseNoContent|Any CPU.Build.0 = Release|Any CPU + {3B2AEA8E-4384-48D8-B26B-2C67466A1352}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {3B2AEA8E-4384-48D8-B26B-2C67466A1352}.Debug|Any CPU.Build.0 = Debug|Any CPU + {3B2AEA8E-4384-48D8-B26B-2C67466A1352}.DebugNoContent|Any CPU.ActiveCfg = Debug|Any CPU + {3B2AEA8E-4384-48D8-B26B-2C67466A1352}.DebugNoContent|Any CPU.Build.0 = Debug|Any CPU + {3B2AEA8E-4384-48D8-B26B-2C67466A1352}.Release|Any CPU.ActiveCfg = Release|Any CPU + {3B2AEA8E-4384-48D8-B26B-2C67466A1352}.Release|Any CPU.Build.0 = Release|Any CPU + {3B2AEA8E-4384-48D8-B26B-2C67466A1352}.ReleaseNoContent|Any CPU.ActiveCfg = Release|Any CPU + {3B2AEA8E-4384-48D8-B26B-2C67466A1352}.ReleaseNoContent|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -53,6 +63,7 @@ Global {C0456069-ED23-4009-BC24-C5B35B25E63B} = {3CE8099E-129D-40F9-8D23-005DFF32E2A2} {ED665F9B-07F4-4415-BD72-A728CF1EA909} = {3CE8099E-129D-40F9-8D23-005DFF32E2A2} {7877D883-AA51-4C27-ADA5-C4F85F86F4EE} = {3CE8099E-129D-40F9-8D23-005DFF32E2A2} + {3B2AEA8E-4384-48D8-B26B-2C67466A1352} = {7877D883-AA51-4C27-ADA5-C4F85F86F4EE} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {8FE3951F-DE18-41FF-A035-32DF597A91F2} diff --git a/P3D/P3D.vbproj b/P3D/P3D.vbproj index b75c51a71..a5328a5f6 100644 --- a/P3D/P3D.vbproj +++ b/P3D/P3D.vbproj @@ -27552,4 +27552,7 @@ + + $(SolutionDir)lib\tools\PostBuild.exe + \ No newline at end of file diff --git a/lib/tools/PostBuild.exe b/lib/tools/PostBuild.exe new file mode 100644 index 000000000..bb01132d7 Binary files /dev/null and b/lib/tools/PostBuild.exe differ diff --git a/lib/tools/PostBuild/App.config b/lib/tools/PostBuild/App.config new file mode 100644 index 000000000..8e1564635 --- /dev/null +++ b/lib/tools/PostBuild/App.config @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lib/tools/PostBuild/PostBuild.csproj b/lib/tools/PostBuild/PostBuild.csproj new file mode 100644 index 000000000..9c6c15703 --- /dev/null +++ b/lib/tools/PostBuild/PostBuild.csproj @@ -0,0 +1,51 @@ + + + + + Debug + AnyCPU + {3B2AEA8E-4384-48D8-B26B-2C67466A1352} + Exe + PostBuild + PostBuild + v4.5 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/lib/tools/PostBuild/Program.cs b/lib/tools/PostBuild/Program.cs new file mode 100644 index 000000000..2b28c2cac --- /dev/null +++ b/lib/tools/PostBuild/Program.cs @@ -0,0 +1,84 @@ +using System; +using System.IO; +using System.Linq; + +namespace PostBuild +{ + class Program + { + private const string SOLUTION_FILENAME = "P3D.sln"; + private const string OUTPUT_DIR = "p3d/bin/Debug"; + + static void Main(string[] args) + { + // find solution folder + var dir = AppDomain.CurrentDomain.BaseDirectory; + string solutionFile = null; + string solutionFolder = null; + + do + { + var files = Directory.GetFiles(dir); + foreach (var file in files) + { + var fileName = Path.GetFileName(file); + if (fileName == SOLUTION_FILENAME) + { + solutionFile = file; + solutionFolder = dir; + } + } + + if (solutionFile == null) + { + // go one folder up and try again + dir = new DirectoryInfo(dir).Parent.FullName; + } + + } while (solutionFile == null); + + var libFolder = Path.Combine(solutionFolder, "lib"); + var buildFolder = Path.Combine(libFolder, "build"); + + // create lib/build + if (!Directory.Exists(buildFolder)) + { + Console.WriteLine($"Created build folder at {buildFolder}"); + Directory.CreateDirectory(buildFolder); + } + + var binFolder = Path.Combine(solutionFolder, "p3d/bin/Debug"); + if (Directory.Exists(binFolder)) + { + var copiedCount = 0; + var binFolderUri = new Uri(binFolder); + var binaries = GetFiles(binFolder, new[] { "*.exe", "*.dll", "*.xnb" }, SearchOption.AllDirectories); + foreach (var binary in binaries) + { + var binaryUri = new Uri(binary); + var relative = binFolderUri.MakeRelativeUri(binaryUri).ToString(); + relative = relative.Remove(0, "Debug\\".Length); + + var targetFile = Path.Combine(buildFolder, relative); + var targetDir = Path.GetDirectoryName(targetFile); + + // create dir + if (!Directory.Exists(targetDir)) + { + Directory.CreateDirectory(targetDir); + } + + File.Copy(binary, targetFile, true); + copiedCount++; + } + + Console.WriteLine($"Copied {copiedCount} files to the build directory."); + } + } + + private static string[] GetFiles(string dir, string[] filters, SearchOption searchOption) + { + return filters.SelectMany(filter => Directory.GetFiles(dir, filter, searchOption)).ToArray(); + } + } +} diff --git a/lib/tools/PostBuild/Properties/AssemblyInfo.cs b/lib/tools/PostBuild/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..04aa9da1d --- /dev/null +++ b/lib/tools/PostBuild/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("PostBuild")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("PostBuild")] +[assembly: AssemblyCopyright("Copyright © 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("3b2aea8e-4384-48d8-b26b-2c67466a1352")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")]