Skip to content

Commit

Permalink
Moved dlls to ModTek/bin to keep dlls in one place
Browse files Browse the repository at this point in the history
  • Loading branch information
CptMoore committed Feb 4, 2024
1 parent dac713c commit a0c5247
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 28 deletions.
3 changes: 2 additions & 1 deletion Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
<ItemGroup>
<PackageVersion Include="Krafs.Publicizer" Version="2.2.1" />
<PackageVersion Include="GitVersion.MsBuild" Version="5.12.0" />
<!-- <PackageVersion Include="HarmonyX" Version="2.11.0" />-->
<PackageVersion Include="HarmonyX" Version="2.10.2" />
<PackageVersion Include="PolySharp" Version="1.13.2" />
<PackageVersion Include="PolySharp" Version="1.14.1" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion HarmonyXInterop/Harmony109Interop/Harmony109Interop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<Target Name="CopyFilesToGame" AfterTargets="CopyFilesToOutputDirectory">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\Harmony12X\" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\bin\" />
</Target>
<ItemGroup>
<ProjectReference Include="..\HarmonyXInterop\HarmonyXInterop.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion HarmonyXInterop/Harmony12Interop/Harmony12Interop.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<Target Name="CopyFilesToGame" AfterTargets="CopyFilesToOutputDirectory">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\Harmony12X\" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\bin\" />
</Target>
<ItemGroup>
<ProjectReference Include="..\HarmonyXInterop\HarmonyXInterop.csproj" />
Expand Down
2 changes: 1 addition & 1 deletion HarmonyXInterop/HarmonyXInterop/HarmonyXInterop.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Import Project="..\..\Common.props" />
<Target Name="CopyFilesToGame" AfterTargets="CopyFilesToOutputDirectory">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\Harmony12X\" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\bin\" />
</Target>
<ItemGroup>
<PackageReference Include="GitVersion.MsBuild">
Expand Down
2 changes: 1 addition & 1 deletion ModTek.Common/ModTek.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Import Project="..\Common.props" />

<Target Name="CopyFilesToGame" AfterTargets="CopyFilesToOutputDirectory">
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\bin\" />
</Target>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion ModTek/ModTek.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
</PropertyGroup>

<Target Name="CopyFilesToGame" AfterTargets="CopyFilesToOutputDirectory">
<Copy SourceFiles="$(TargetPath);@(Asset)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\bin\" />
<Copy SourceFiles="@(Asset)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\" />
</Target>

<PropertyGroup>
Expand Down
5 changes: 4 additions & 1 deletion ModTekInjector/ModTekInjector.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
<PackageReference Include="GitVersion.MsBuild">
<PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="HarmonyX" />
<PackageReference Include="HarmonyX">
<PrivateAssets>All</PrivateAssets>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference>
<PackageReference Include="PolySharp">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
Expand Down
8 changes: 2 additions & 6 deletions ModTekPreloader/Harmony12X/DynamicShimInjector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@ internal static void Setup()
private DynamicShimInjector()
{
Logger.Main.Log("Setting up HarmonyX interoperability");
if (!Directory.Exists(Paths.Harmony12XDirectory))
{
throw new Exception($"HarmonyX can't be loaded, directory `{FileUtils.GetRelativePath(Paths.Harmony12XDirectory)}` missing.");
}

Logger.Main.Log($"Preloading supported Harmony12X assemblies from `{FileUtils.GetRelativePath(Paths.Harmony12XDirectory)}`.");
Logger.Main.Log($"Preloading supported Harmony12X assemblies from `{FileUtils.GetRelativePath(Paths.ModTekBinDirectory)}`.");
foreach (var harmonyVersion in HarmonyVersion.SupportedVersions)
{
var file = Path.Combine(Paths.Harmony12XDirectory, $"{harmonyVersion.Name}.dll");
var file = Path.Combine(Paths.ModTekBinDirectory, $"{harmonyVersion.Name}.dll");
Logger.Main.Log($"\t{Path.GetFileName(file)}");
var assembly = Assembly.LoadFile(file);
if (!harmonyVersion.IsMatch(assembly.GetName().Version))
Expand Down
2 changes: 1 addition & 1 deletion ModTekPreloader/Injector/AssemblyCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal AssemblyCache()
{
searchDirectories = new List<string>
{
Paths.ModTekDirectory,
Paths.ModTekBinDirectory,
Paths.ManagedDirectory
};

Expand Down
8 changes: 2 additions & 6 deletions ModTekPreloader/Injector/InjectionCacheManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,15 @@ internal static string GetActualManifestContent()

// preloader
files.Add(Paths.PreloaderConfigFile);
if (Directory.Exists(Paths.ModTekDirectory))
if (Directory.Exists(Paths.ModTekBinDirectory))
{
files.AddRange(Directory.GetFiles(Paths.ModTekDirectory, "*.dll"));
files.AddRange(Directory.GetFiles(Paths.ModTekBinDirectory, "*.dll"));
}
files.AddRange(Directory.GetFiles(Paths.InjectorsDirectory));
if (Directory.Exists(Paths.AssembliesOverrideDirectory))
{
files.AddRange(Directory.GetFiles(Paths.AssembliesOverrideDirectory, "*.dll"));
}
if (Directory.Exists(Paths.Harmony12XDirectory))
{
files.AddRange(Directory.GetFiles(Paths.Harmony12XDirectory, "*.dll"));
}

// output
if (Directory.Exists(Paths.AssembliesInjectedDirectory))
Expand Down
2 changes: 1 addition & 1 deletion ModTekPreloader/Loader/Preloader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ private static void PreloadAssembliesOverride()

private static void PreloadModTek()
{
var file = Path.Combine(Paths.ModTekDirectory, "ModTek.dll");
var file = Path.Combine(Paths.ModTekBinDirectory, "ModTek.dll");
Logger.Main.Log($"Preloading ModTek from `{FileUtils.GetRelativePath(file)}`:");
Assembly.LoadFile(file);
}
Expand Down
8 changes: 3 additions & 5 deletions ModTekPreloader/ModTekPreloader.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@

<Target Name="CopyFilesToGame" AfterTargets="CopyFilesToOutputDirectory">
<ItemGroup>
<ModTekDepFiles Include="$(OutDir)\Mono.Cecil*" />
<Harmony12XDeps Exclude="$(OutDir)\Mono.Cecil*;$(TargetPath)" Include="$(OutDir)**" />
<Harmony12XDeps Exclude="$(TargetPath)" Include="$(OutDir)**" />
<DoorstopFiles Include="run.sh;doorstop_config.ini" />
</ItemGroup>
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\" />
<Copy SourceFiles="@(ModTekDepFiles)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\" />
<Copy SourceFiles="@(Harmony12XDeps)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\Harmony12X\" />
<Copy SourceFiles="$(TargetPath)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\bin\" />
<Copy SourceFiles="@(Harmony12XDeps)" DestinationFolder="$(BattleTechGameDir)\Mods\ModTek\bin\" />
<Copy SourceFiles="@(DoorstopFiles)" DestinationFolder="$(BattleTechGameDir)\" />
<MakeDir Directories="$(BattleTechGameDir)\Mods\ModTek\AssembliesOverride" />
</Target>
Expand Down
2 changes: 1 addition & 1 deletion ModTekPreloader/Paths.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ internal class Paths
internal static readonly string PreloaderConfigFile = Path.Combine(ModTekDirectory, "ModTekPreloader.config.json");
internal static readonly string PreloaderConfigDefaultsFile = Path.Combine(ModTekDirectory, "ModTekPreloader.config.help.json");
internal static readonly string AssembliesOverrideDirectory = Path.Combine(ModTekDirectory, "AssembliesOverride");
internal static readonly string Harmony12XDirectory = Path.Combine(ModTekDirectory, "Harmony12X");
internal static readonly string ModTekBinDirectory = Path.Combine(ModTekDirectory, "bin");
internal static readonly string HarmonyLogFile = Path.Combine(DotModTekDirectory, "HarmonyFileLog.log");
internal static readonly string LogFile = Path.Combine(DotModTekDirectory, "ModTekPreloader.log");
internal static readonly string LockFile = Path.Combine(DotModTekDirectory, "ModTekPreloader.lock");
Expand Down
2 changes: 1 addition & 1 deletion ModTekPreloader/doorstop_config.ini
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[General]
enabled=true
target_assembly=Mods\ModTek\ModTekPreloader.dll
target_assembly=Mods\ModTek\bin\ModTekPreloader.dll
# If true, Unity's output log is redirected to <current folder>\output_log.txt
redirect_output_log=false
# Options specific to running under Unity Mono runtime
Expand Down

0 comments on commit a0c5247

Please sign in to comment.