From e11bd9639e6b86a03b86b04addf4b22ed618a2f2 Mon Sep 17 00:00:00 2001 From: nilllzz Date: Thu, 22 Feb 2018 16:43:57 +0100 Subject: [PATCH] add post build tool that copies binaries into build folder --- P3D.sln | 11 +++ P3D/P3D.vbproj | 3 + lib/tools/PostBuild.exe | Bin 0 -> 6656 bytes lib/tools/PostBuild/App.config | 6 ++ lib/tools/PostBuild/PostBuild.csproj | 51 +++++++++++ lib/tools/PostBuild/Program.cs | 84 ++++++++++++++++++ .../PostBuild/Properties/AssemblyInfo.cs | 36 ++++++++ 7 files changed, 191 insertions(+) create mode 100644 lib/tools/PostBuild.exe create mode 100644 lib/tools/PostBuild/App.config create mode 100644 lib/tools/PostBuild/PostBuild.csproj create mode 100644 lib/tools/PostBuild/Program.cs create mode 100644 lib/tools/PostBuild/Properties/AssemblyInfo.cs 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 0000000000000000000000000000000000000000..bb01132d7e3eb9694acd082d87c6a8327461da31 GIT binary patch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g(tuE+Njb- zK8@S`Bg0sis4JzzH;Cp*++ODa$LIuF3H(Acfqnw;Na@!a`jP*=3#EH&Nmu0#d#J1k zC){xCIns?p^ixaf=}Qup7UB7SlY22vbiT6O;mdn3yfk!ZC7UspOIP;;QKXWnA#y1@ zjr-bx=KThz!QR~?8R zE8>!zu~PCy5Hs`nXirIl=M-FzFSsAkp8lwm!`QA!74QTrmixds;*J9B6zM6)TE=a4 zQMeyb>p(@TfwHOx2Yaf(Pn>bFEHXxh;en{>CUVR6Y2ieTf;E!DZ5m-*Ff*{|2bWWbXg~ literal 0 HcmV?d00001 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")]