From 36dc6bc36b712aa91f9bd566c668cac0efe96cf0 Mon Sep 17 00:00:00 2001 From: js6pak Date: Fri, 1 Jan 2021 18:28:25 +0100 Subject: [PATCH] Fix visual studio --- Reactor.OxygenFilter.MSBuild/Context.cs | 3 ++- Reactor.OxygenFilter.MSBuild/LoadMappings.cs | 24 +++++++++++++------ .../Reactor.OxygenFilter.MSBuild.csproj | 4 ++-- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/Reactor.OxygenFilter.MSBuild/Context.cs b/Reactor.OxygenFilter.MSBuild/Context.cs index b3bc47b..c2eaa7d 100644 --- a/Reactor.OxygenFilter.MSBuild/Context.cs +++ b/Reactor.OxygenFilter.MSBuild/Context.cs @@ -7,7 +7,8 @@ namespace Reactor.OxygenFilter.MSBuild { public static class Context { - public static string DataPath { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), ".reactor"); + // Path#Combine is borken on visual studio + public static string DataPath { get; } = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + Path.DirectorySeparatorChar + ".reactor"; public static string TempPath { get; } = Path.Combine(DataPath, "temp"); public static string ComputeHash(FileInfo file) diff --git a/Reactor.OxygenFilter.MSBuild/LoadMappings.cs b/Reactor.OxygenFilter.MSBuild/LoadMappings.cs index 96fee98..3415bc1 100644 --- a/Reactor.OxygenFilter.MSBuild/LoadMappings.cs +++ b/Reactor.OxygenFilter.MSBuild/LoadMappings.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using System.Net.Http; using Microsoft.Build.Framework; @@ -23,8 +24,13 @@ public override bool Execute() return true; } - Directory.CreateDirectory(Context.TempPath); - var file = Path.Combine(Context.TempPath, Mappings.Replace("/", "_") + $"-{TargetGamePlatform.ToLower()}" + ".json"); + var split = Mappings.Split(':'); + var repo = split[0]; + var version = split[1]; + + var directory = Path.Combine(Context.TempPath, repo.Replace("/", "_"), version); + Directory.CreateDirectory(directory); + var file = Path.Combine(directory, $"{TargetGamePlatform.ToLower()}.json"); if (File.Exists(file)) { @@ -32,15 +38,19 @@ public override bool Execute() return true; } - var split = Mappings.Split(':'); - var repo = split[0]; - var version = split[1]; - var httpClient = new HttpClient(); var json = httpClient.GetStringAsync($"https://github.com/{repo}/releases/download/{version}/{TargetGamePlatform.ToLower()}.json").GetAwaiter().GetResult(); MappingsJson = json; - File.WriteAllText(file, json); + + try + { + File.WriteAllText(file, json); + } + catch (Exception e) + { + Log.LogWarning("Failed to cache " + file + "\n" + e); + } return true; } diff --git a/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.csproj b/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.csproj index b5a996d..78a971c 100644 --- a/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.csproj +++ b/Reactor.OxygenFilter.MSBuild/Reactor.OxygenFilter.MSBuild.csproj @@ -4,7 +4,7 @@ latest true - 0.1.1 + 0.1.2 git https://github.com/NuclearPowered/Reactor.OxygenFilter LGPL-3.0-or-later @@ -31,7 +31,7 @@ - <_PackageFiles Include="bin\$(Configuration)\*\Reactor.OxygenFilter.dll;bin\$(Configuration)\*\Newtonsoft.Json.dll;bin\$(Configuration)\*\Il2CppDumper.dll;bin\$(Configuration)\*\AssemblyUnhollower.dll;bin\$(Configuration)\*\Unhollower*Lib.dll;bin\$(Configuration)\*\Iced.dll;bin\$(Configuration)\*\Mono.*.dll"> + <_PackageFiles Include="bin\$(Configuration)\*\Reactor.OxygenFilter.dll;bin\$(Configuration)\*\Newtonsoft.Json.dll;bin\$(Configuration)\*\Il2CppDumper.dll;bin\$(Configuration)\*\AssemblyUnhollower.*;bin\$(Configuration)\*\Unhollower*Lib.dll;bin\$(Configuration)\*\Iced.dll;bin\$(Configuration)\*\Mono.*.dll"> lib%(RecursiveDir) false Content