Skip to content

Commit

Permalink
WIP shift to net9 and static hooks
Browse files Browse the repository at this point in the history
This includes package updates, including steamworks upgrades
  • Loading branch information
SignatureBeef committed Dec 28, 2024
1 parent 24d30d3 commit 6114a1b
Show file tree
Hide file tree
Showing 24 changed files with 548 additions and 432 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/ci-launcher.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,26 +56,26 @@ jobs:
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- uses: actions/setup-dotnet@v2
with:
dotnet-version: '6.0.x' # SDK Version to use; x will use the latest version of the 3.1 channel
dotnet-version: '9.0.x' # SDK Version to use; x will use the latest version of the 3.1 channel

# - name: MonoMod dev build
# run: dotnet nuget add source https://pkgs.dev.azure.com/MonoMod/MonoMod/_packaging/DevBuilds%40Local/nuget/v3/index.json -n DevBuilds@Local

- name: Build
run: |
cd OTAPI.Client.Launcher
dotnet publish -r ${{ matrix.profile.runtime_identifier }} --framework net6.0 -p:PublishReadyToRun=true --self-contained false -c Release
dotnet publish -r ${{ matrix.profile.runtime_identifier }} --framework net9.0 -p:PublishReadyToRun=true --self-contained false -c Release
if ${{ matrix.profile.runs_on != 'macos-latest' }} ; then
7z a ../${{ matrix.profile.archive_name }} './bin/Release/net6.0/${{ matrix.profile.runtime_identifier }}/publish/*'
7z a ../${{ matrix.profile.archive_name }} './bin/Release/net9.0/${{ matrix.profile.runtime_identifier }}/publish/*'
else
mkdir -p OTAPI.app/Contents/Resources
mv bin/Release/net6.0/osx-x64/publish OTAPI.app/Contents/MacOS
mv bin/Release/net9.0/osx-x64/publish OTAPI.app/Contents/MacOS
cp ../docs/MacOS.Info.plist OTAPI.app/Contents/Info.plist
cp OTAPI.osx.sh OTAPI.app/Contents/MacOS/OTAPI
chmod +x OTAPI.app/Contents/MacOS/OTAPI
Expand All @@ -85,7 +85,7 @@ jobs:
# - uses: actions/upload-artifact@v2
# with:
# name: ${{ matrix.profile.name }} Launcher
# path: OTAPI.Client.Launcher/bin/Release/net6.0/${{ matrix.profile.runtime_identifier }}/publish
# path: OTAPI.Client.Launcher/bin/Release/net9.0/${{ matrix.profile.runtime_identifier }}/publish

- uses: "marvinpinto/action-automatic-releases@latest"
with:
Expand Down
24 changes: 12 additions & 12 deletions .github/workflows/ci-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,38 +36,38 @@ jobs:
name: ${{ matrix.profile.name }} Server

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- uses: actions/setup-dotnet@v3
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '9.0.x'

- name: Build the project
run: |
dotnet build OTAPI.Mods.slnf
(cd OTAPI.Patcher/bin/Debug/net6.0 && exec dotnet run --project ../../../OTAPI.Patcher.csproj -patchTarget=${{ matrix.profile.patch_target }} -latest=n --framework net6.0)
(cd OTAPI.Patcher/bin/Debug/net9.0 && exec dotnet run --project ../../../OTAPI.Patcher.csproj -patchTarget=${{ matrix.profile.patch_target }} -latest=n --framework net9.0)
dotnet build OTAPI.Server.Launcher.slnf
(cd OTAPI.Server.Launcher/bin/Debug/net6.0 && exec dotnet OTAPI.Server.Launcher.dll -test-init)
(cd OTAPI.Server.Launcher/bin/Debug/net9.0 && exec dotnet OTAPI.Server.Launcher.dll -test-init)
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.profile.name }} NuGet Package
path: OTAPI.Patcher/bin/Debug/net6.0/${{ matrix.profile.package_path }}
path: OTAPI.Patcher/bin/Debug/net9.0/${{ matrix.profile.package_path }}

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.profile.name }} Binaries
path: |
OTAPI.Patcher/bin/Debug/net6.0/artifact-*/*
OTAPI.Patcher/bin/Debug/net9.0/artifact-*/*
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.profile.name }} Wiki MD files
path: OTAPI.Patcher/bin/Debug/net6.0/*.mfw.md
path: OTAPI.Patcher/bin/Debug/net9.0/*.mfw.md

- name: "Releasing to NuGet: ${{ matrix.profile.name }}"
env:
NUGET_API_KEY: ${{ secrets.NUGET_API_KEY }}
run: dotnet nuget push OTAPI.Patcher/bin/Debug/net6.0/${{ matrix.profile.package_path }} --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY"
run: dotnet nuget push OTAPI.Patcher/bin/Debug/net9.0/${{ matrix.profile.package_path }} --source https://api.nuget.org/v3/index.json --api-key "$NUGET_API_KEY"
22 changes: 11 additions & 11 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,33 @@ jobs:
name: ${{ matrix.profile.name }} Server

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- uses: actions/setup-dotnet@v3
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '6.0.x'
dotnet-version: '9.0.x'

- name: Build the project
run: |
dotnet build OTAPI.Mods.slnf
(cd OTAPI.Patcher/bin/Debug/net6.0 && exec dotnet run --project ../../../OTAPI.Patcher.csproj -patchTarget=${{ matrix.profile.patch_target }} -latest=n --framework net6.0)
(cd OTAPI.Patcher/bin/Debug/net9.0 && exec dotnet run --project ../../../OTAPI.Patcher.csproj -patchTarget=${{ matrix.profile.patch_target }} -latest=n --framework net9.0)
dotnet build OTAPI.Server.Launcher.slnf
(cd OTAPI.Server.Launcher/bin/Debug/net6.0 && exec dotnet OTAPI.Server.Launcher.dll -test-init)
(cd OTAPI.Server.Launcher/bin/Debug/net9.0 && exec dotnet OTAPI.Server.Launcher.dll -test-init)
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.profile.name }} NuGet Package
path: OTAPI.Patcher/bin/Debug/net6.0/${{ matrix.profile.package_path }}
path: OTAPI.Patcher/bin/Debug/net9.0/${{ matrix.profile.package_path }}

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.profile.name }} Binaries
path: |
OTAPI.Patcher/bin/Debug/net6.0/artifact-*/*
OTAPI.Patcher/bin/Debug/net9.0/artifact-*/*
- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.profile.name }} Wiki MD files
path: OTAPI.Patcher/bin/Debug/net6.0/*.mfw.md
path: OTAPI.Patcher/bin/Debug/net9.0/*.mfw.md
12 changes: 6 additions & 6 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
"request": "launch",
"preLaunchTask": "build-setup",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/OTAPI.Setup/bin/Debug/net6.0/OTAPI.Setup.dll",
"program": "${workspaceFolder}/OTAPI.Setup/bin/Debug/net9.0/OTAPI.Setup.dll",
"args": ["-patchTarget=v", "-latestVanilla=n"],
"cwd": "${workspaceFolder}/OTAPI.Setup/bin/Debug/net6.0/",
"cwd": "${workspaceFolder}/OTAPI.Setup/bin/Debug/net9.0/",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
Expand All @@ -23,9 +23,9 @@
"request": "launch",
"preLaunchTask": "build-mods",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/OTAPI.Patcher/bin/Debug/net6.0/OTAPI.Patcher.dll",
"program": "${workspaceFolder}/OTAPI.Patcher/bin/Debug/net9.0/OTAPI.Patcher.dll",
"args": ["-patchTarget=v", "-latestVanilla=n"],
"cwd": "${workspaceFolder}/OTAPI.Patcher/bin/Debug/net6.0/",
"cwd": "${workspaceFolder}/OTAPI.Patcher/bin/Debug/net9.0/",
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "internalConsole",
"stopAtEntry": false
Expand All @@ -36,9 +36,9 @@
"request": "launch",
"preLaunchTask": "build-launcher",
// If you have changed target frameworks, make sure to update the program path.
"program": "${workspaceFolder}/OTAPI.Launcher/bin/Debug/net6.0/OTAPI.Launcher.dll",
"program": "${workspaceFolder}/OTAPI.Launcher/bin/Debug/net9.0/OTAPI.Launcher.dll",
"args": ["-patchTarget=v", "-latestVanilla=n"],
"cwd": "${workspaceFolder}/OTAPI.Launcher/bin/Debug/net6.0/", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"cwd": "${workspaceFolder}/OTAPI.Launcher/bin/Debug/net9.0/", // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
"console": "externalTerminal",
"stopAtEntry": false
},
Expand Down
7 changes: 5 additions & 2 deletions OTAPI.Client.Launcher/App.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
<Application.Resources>
<themes:BundledTheme BaseTheme="Light" PrimaryColor="Teal" SecondaryColor="Amber"/>
</Application.Resources>
<Application.Styles>
<!--<Application.Styles>
<StyleInclude Source="avares://Avalonia.Themes.Default/DefaultTheme.xaml"/>
<StyleInclude Source="avares://Avalonia.Themes.Default/Accents/BaseLight.xaml"/>
<StyleInclude Source="avares://Material.Avalonia/Material.Avalonia.Templates.xaml" />
</Application.Styles>
</Application.Styles>-->
<Application.Styles>
<themes:MaterialTheme BaseTheme="Dark" PrimaryColor="Purple" SecondaryColor="Lime" />
</Application.Styles>
</Application>
6 changes: 2 additions & 4 deletions OTAPI.Client.Launcher/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@
Plugins
</TextBlock>
<ScrollViewer Height="200" Classes="scrollview">
<ItemsControl Items="{Binding Plugins}">
<ItemsControl ItemsSource="{Binding Plugins}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<CheckBox Margin="4"
Expand All @@ -184,10 +184,8 @@
Status
</TextBlock>
<ScrollViewer Height="100" Classes="scrollview">
<!--<TextBlock Classes="installStatus"
Text="{Binding InstallStatus}" />-->

<ItemsControl Items="{Binding Console}">
<ItemsControl ItemsSource="{Binding Console}">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Margin="5" Text="{Binding}" />
Expand Down
2 changes: 1 addition & 1 deletion OTAPI.Client.Launcher/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ private void OnConsoleLineReceived(string line)
Context.Console.Insert(0, $"[{DateTime.Now:yyyyMMdd HH:mm:ss}] {line}");
}

protected override void OnClosing(CancelEventArgs e)
protected override void OnClosing(WindowClosingEventArgs e)
{
base.OnClosing(e);
_watcher?.Dispose();
Expand Down
40 changes: 21 additions & 19 deletions OTAPI.Client.Launcher/OTAPI.Client.Launcher.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<DebugType>embedded</DebugType>
<RunPostBuildEvent>Always</RunPostBuildEvent>
Expand All @@ -27,15 +27,17 @@
<None Include="csharp\plugins\scripts\otapi\test-runtime.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.18" />
<PackageReference Include="Avalonia.Desktop" Version="0.10.18" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.18" />
<PackageReference Include="CefGlue.Avalonia" Version="91.4472.30" />
<PackageReference Include="CefGlue.Common" Version="91.4472.30" />
<PackageReference Include="Material.Avalonia" Version="2.5.1" />
<PackageReference Include="Projektanker.Icons.Avalonia.FontAwesome" Version="5.5.0" />
<PackageReference Include="ReactiveUI" Version="18.3.1" />
<PackageReference Include="System.Reactive.Linq" Version="5.0.0" />
<PackageReference Include="Avalonia" Version="11.2.3" />
<PackageReference Include="Avalonia.Desktop" Version="11.2.3" />
<PackageReference Include="Avalonia.Diagnostics" Version="11.2.3" />
<PackageReference Include="CefGlue.Avalonia" Version="120.6099.210" />
<PackageReference Include="CefGlue.Common" Version="120.6099.210" />
<PackageReference Include="Material.Avalonia" Version="3.9.1" />
<PackageReference Include="Projektanker.Icons.Avalonia.FontAwesome" Version="9.6.0" />
<PackageReference Include="ReactiveUI" Version="20.1.63" />
<PackageReference Include="Steamworks.NET" Version="2024.8.0" />
<PackageReference Include="System.Private.Uri" Version="4.3.2" />
<PackageReference Include="System.Reactive.Linq" Version="6.0.1" />
<PackageReference Include="Microsoft.Win32.Registry" Version="6.0.0-preview.5.21301.5" GeneratePathProperty="true" />
</ItemGroup>
<ItemGroup>
Expand All @@ -48,12 +50,12 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<PackageReference Include="ImGui.NET" Version="1.87.3" GeneratePathProperty="true" />
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.7" GeneratePathProperty="true" />
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.7" GeneratePathProperty="true" />
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.7" GeneratePathProperty="true" />
<PackageReference Include="MonoMod.RuntimeDetour.HookGen" Version="22.5.1.1" />
<PackageReference Include="SharpZipLib" Version="1.4.0" />
<PackageReference Include="ImGui.NET" Version="1.91.0.1" GeneratePathProperty="true" />
<PackageReference Include="ModFramework.Modules.ClearScript" Version="1.1.9" GeneratePathProperty="true" />
<PackageReference Include="ModFramework.Modules.CSharp" Version="1.1.9" GeneratePathProperty="true" />
<PackageReference Include="ModFramework.Modules.Lua" Version="1.1.9" GeneratePathProperty="true" />
<PackageReference Include="MonoMod.RuntimeDetour.HookGen" Version="22.7.31.1" />
<PackageReference Include="SharpZipLib" Version="1.4.2" />
<PackageReference Include="System.Collections.Specialized" Version="4.3.0" />
<PackageReference Include="System.Drawing.Primitives" Version="4.3.0" />
</ItemGroup>
Expand Down Expand Up @@ -121,7 +123,7 @@
<Copy SourceFiles="@(ClientLua)" DestinationFolder="$(TargetDir)lua/%(RecursiveDir)" />

<Copy SourceFiles="$(PkgMicrosoft_Win32_Registry)/lib/netstandard2.0/Microsoft.Win32.Registry.dll" DestinationFolder="$(TargetDir)" SkipUnchangedFiles="false" />
<Copy SourceFiles="$(PkgImGui_NET)/runtimes/osx-universal/native/libcimgui.dylib" DestinationFolder="$(TargetDir)" SkipUnchangedFiles="false" />
<Copy SourceFiles="$(PkgImGui_NET)/runtimes/osx/native/libcimgui.dylib" DestinationFolder="$(TargetDir)" SkipUnchangedFiles="false" />
</Target>
<Target Name="AfterPrepareForPublish" AfterTargets="Publish">
<Message Text="Copying release OTAPI patch files" Importance="high" />
Expand Down Expand Up @@ -215,7 +217,7 @@
</Target>
<Target Name="CreateScriptAfterPublish" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)' != 'win-x64'">
<Copy SourceFiles="$(ProjectDir)OTAPI.sh" DestinationFolder="$(PublishDir)" />
<Exec Command="chmod +x $(PublishDir)OTAPI.sh" />
<Message Text="Run the launcher with: cd bin/$(Configuration)/$(TargetFramework)/$(RuntimeIdentifier)/publish &amp;&amp; ./OTAPI.sh" Importance="High" />
<Exec Command="chmod +x $(PublishDir)OTAPI.sh" />
<Message Text="Run the launcher with: cd bin/$(Configuration)/$(TargetFramework)/$(RuntimeIdentifier)/publish &amp;&amp; ./OTAPI.sh" Importance="High" />
</Target>
</Project>
5 changes: 2 additions & 3 deletions OTAPI.Client.Launcher/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ static void Start(string[] args)
plg.OnEnabledChanged += OnPluginChanged;

// start the launcher, then OTAPI if requested
IconProvider.Current.Register(new FontAwesomeIconProvider());
BuildAvaloniaApp()
.StartWithClassicDesktopLifetime(args);

Expand All @@ -189,7 +190,5 @@ private static void OnPluginChanged(object? sender, EventArgs e)
public static AppBuilder BuildAvaloniaApp()
=> AppBuilder.Configure<App>()
.UsePlatformDetect()
.LogToTrace()
.WithIcons(container => container
.Register<FontAwesomeIconProvider>());
.LogToTrace();
}
33 changes: 3 additions & 30 deletions OTAPI.Client.Launcher/Targets/InstallTarget.Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public static void CopyOTAPI(this IPlatformTarget target, string otapiFolder, IE

File.WriteAllText(Path.Combine(otapiFolder, "Terraria.runtimeconfig.json"), @"{
""runtimeOptions"": {
""tfm"": ""net6.0"",
""tfm"": ""net9.0"",
""framework"": {
""name"": ""Microsoft.NETCore.App"",
""version"": ""5.0.0""
Expand Down Expand Up @@ -241,8 +241,6 @@ public static IEnumerable<string> PublishHostGame(this IPlatformTarget target)
compilation = compilation.AddReferences(MetadataReference.CreateFromFile("ImGui.NET.dll"));
compilation = compilation.AddReferences(MetadataReference.CreateFromFile("OTAPI.exe"));
compilation = compilation.AddReferences(MetadataReference.CreateFromFile("OTAPI.Runtime.dll"));
//compilation = compilation.AddReferences(MetadataReference.CreateFromFile(Path.Combine(hostDir, @"..\OTAPI.Client.Installer\bin\Debug\net6.0\OTAPI.exe")));
//compilation = compilation.AddReferences(MetadataReference.CreateFromFile(Path.Combine(hostDir, @"..\OTAPI.Client.Installer\bin\Debug\net6.0\OTAPI.Runtime.dll")));

var outPdbPath = Path.Combine(output, "OTAPI.Client.Installer.pdb");
var emitOptions = new EmitOptions(
Expand Down Expand Up @@ -341,31 +339,6 @@ public static string PublishHostLauncher(this IPlatformTarget target)
return Path.GetDirectoryName(files.Single(x => Path.GetFileName(x).Equals("Terraria.exe", StringComparison.CurrentCultureIgnoreCase)));
else // linux+osx
return Path.GetDirectoryName(files.Single(x => Path.GetFileName(x).Equals("Terraria", StringComparison.CurrentCultureIgnoreCase)));

//Console.WriteLine(target.Status = "Building launcher, this may take a long time...");
//var hostDir = "../../../../OTAPI.Client.Launcher/";

//var package = RuntimeInformation.IsOSPlatform(OSPlatform.Windows)
// ? "win-x64" : (
// RuntimeInformation.IsOSPlatform(OSPlatform.OSX) ? "osx.10.11-x64" : "ubuntu.16.04-x64"
//);

//using var process = new System.Diagnostics.Process()
//{
// StartInfo = new System.Diagnostics.ProcessStartInfo()
// {
// FileName = "dotnet",
// Arguments = $"publish -r {package} --framework net6.0 -p:PublishTrimmed=true -p:PublishSingleFile=true -p:PublishReadyToRun=true --self-contained true -c Release",
// //Arguments = "msbuild -restore -t:PublishAllRids",
// WorkingDirectory = hostDir
// },
//};
//process.Start();
//process.WaitForExit();

//Console.WriteLine("Published");

//return Path.Combine(hostDir, "bin", "Release", "net6.0", package, "publish");
}

public static string DownloadZip(this IPlatformTarget target, string url, string name)
Expand Down Expand Up @@ -436,8 +409,8 @@ public static void GenerateTypings(this IPlatformTarget target, string rootFolde
if (File.Exists(dll))
return Assembly.LoadFile(dll);

exe = Path.Combine(patcherDir, "bin", "Debug", "net6.0", "EmbeddedResources", $"{asr.Name}.exe");
dll = Path.Combine(patcherDir, "bin", "Debug", "net6.0", "EmbeddedResources", $"{asr.Name}.dll");
exe = Path.Combine(patcherDir, "bin", "Debug", "net9.0", "EmbeddedResources", $"{asr.Name}.exe");
dll = Path.Combine(patcherDir, "bin", "Debug", "net9.0", "EmbeddedResources", $"{asr.Name}.dll");

if (File.Exists(exe))
return Assembly.LoadFile(exe);
Expand Down
Loading

0 comments on commit 6114a1b

Please sign in to comment.