Skip to content

Commit b689c76

Browse files
committed
[Update] Create a .targets file instad of copying libraries
1 parent 89945c7 commit b689c76

File tree

2 files changed

+27
-20
lines changed

2 files changed

+27
-20
lines changed

Program.cs

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,47 @@
11
using NativeFileDialogSharp;
22
using System;
33
using System.IO;
4+
using System.Linq;
45
using System.Threading;
56

67
public class Program
78
{
8-
static string OutputLibPath = AppDomain.CurrentDomain.SetupInformation.ApplicationBase.Replace("RL2.ModLoader.DevSetup\\", "") + "lib\\";
9+
static string OutputPath = string.Join('\\', AppDomain.CurrentDomain.SetupInformation.ApplicationBase!.Split("\\").SkipLast(1));
910

1011
public static void Main(string[] args) {
1112
Console.WriteLine("Welcome to the RL2.ModLoader.DevSetup");
12-
Console.WriteLine("Choose your games installation directory");
13+
Console.WriteLine("Choose your game's .exe file");
1314
Thread.Sleep(500);
1415

15-
DialogResult result = Dialog.FolderPicker();
16-
string DataPath = result.Path + "\\Rogue Legacy 2_Data";
16+
DialogResult result = Dialog.FileOpen();
17+
string directory = result.Path.Replace("\\Rogue Legacy 2.exe", "");
18+
string DataPath = directory + "\\Rogue Legacy 2_Data";
1719
string ManagedPath = DataPath + "\\Managed";
1820

19-
if (!Directory.Exists(DataPath) || !Directory.Exists(ManagedPath)) {
21+
if (!File.Exists(directory + "\\Rogue Legacy 2.exe")) {
2022
Console.WriteLine("The provided path is incorrect");
23+
Console.WriteLine("The selected folder should contain the 'Rogue Legacy 2.exe' file");
2124
return;
2225
}
2326

24-
if (!Directory.Exists(OutputLibPath)) {
25-
Directory.CreateDirectory(OutputLibPath);
26-
}
27+
File.WriteAllText(OutputPath + "RL2.ModLoader.targets", $"""
28+
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
29+
<!-- MSBuild variables -->
30+
<PropertyGroup>
31+
<RL2_Path>{directory}</RL2_Path>
32+
<RL2_DataPath>{DataPath}</RL2_DataPathPath>
33+
<RL2_LibPath>{DataPath}</RL2_LibPath>
34+
</PropertyGroup>
2735
28-
Console.WriteLine("\nStart copying libs...");
29-
DirectoryInfo librariesDirectory = new DirectoryInfo(ManagedPath);
30-
foreach (FileInfo fileInfo in librariesDirectory.GetFiles("**.dll")) {
31-
if (fileInfo.Name == "RL2.ModLoader.dll" || fileInfo.Name == "RL2.API.dll") {
32-
continue;
33-
}
34-
Console.WriteLine(fileInfo.Name);
35-
File.Copy(fileInfo.FullName, OutputLibPath + fileInfo.Name, true);
36-
}
37-
Console.WriteLine("Press any key to exit...");
38-
Console.ReadKey();
36+
<!-- Shared references -->
37+
<ItemGroup>
38+
<Reference Include="{ManagedPath}\*.dll" />
39+
</ItemGroup>
40+
</Project>
41+
""");
42+
43+
Console.WriteLine($"RL2.ModLoader.targets created in {OutputPath}");
44+
Console.WriteLine("Closing in 2 seconds...");
45+
Thread.Sleep(2_000);
3946
}
4047
}

RL2.ModLoader.DevSetup.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
5-
<TargetFramework>net48</TargetFramework>
5+
<TargetFramework>net8</TargetFramework>
66
<LangVersion>latest</LangVersion>
77
<Nullable>enable</Nullable>
88
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

0 commit comments

Comments
 (0)