mirror of
https://github.com/P3D-Legacy/P3D-Legacy.git
synced 2025-04-08 18:35:09 +02:00
add post build tool that copies binaries into build folder
This commit is contained in:
parent
79999983c0
commit
e11bd9639e
11
P3D.sln
11
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}
|
||||
|
@ -27552,4 +27552,7 @@
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.VisualBasic.targets" />
|
||||
<Import Condition=" '$(Configuration)' != 'DebugNoContent' Or '$(Configuration)' != 'ReleaseNoContent' " Project="$(MSBuildExtensionsPath)\MonoGame\v3.0\MonoGame.Content.Builder.targets" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>$(SolutionDir)lib\tools\PostBuild.exe</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
</Project>
|
BIN
lib/tools/PostBuild.exe
Normal file
BIN
lib/tools/PostBuild.exe
Normal file
Binary file not shown.
6
lib/tools/PostBuild/App.config
Normal file
6
lib/tools/PostBuild/App.config
Normal file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
|
||||
</startup>
|
||||
</configuration>
|
51
lib/tools/PostBuild/PostBuild.csproj
Normal file
51
lib/tools/PostBuild/PostBuild.csproj
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{3B2AEA8E-4384-48D8-B26B-2C67466A1352}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>PostBuild</RootNamespace>
|
||||
<AssemblyName>PostBuild</AssemblyName>
|
||||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<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.Net.Http" />
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
84
lib/tools/PostBuild/Program.cs
Normal file
84
lib/tools/PostBuild/Program.cs
Normal file
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
36
lib/tools/PostBuild/Properties/AssemblyInfo.cs
Normal file
36
lib/tools/PostBuild/Properties/AssemblyInfo.cs
Normal file
@ -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")]
|
Loading…
x
Reference in New Issue
Block a user