Skip to content
This repository has been archived by the owner on Jul 26, 2021. It is now read-only.

Commit

Permalink
Fix visual studio
Browse files Browse the repository at this point in the history
  • Loading branch information
js6pak committed Jan 1, 2021
1 parent 257a19f commit 36dc6bc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
3 changes: 2 additions & 1 deletion Reactor.OxygenFilter.MSBuild/Context.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 17 additions & 7 deletions Reactor.OxygenFilter.MSBuild/LoadMappings.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Net.Http;
using Microsoft.Build.Framework;
Expand All @@ -23,24 +24,33 @@ 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))
{
MappingsJson = File.ReadAllText(file);
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<LangVersion>latest</LangVersion>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

<Version>0.1.1</Version>
<Version>0.1.2</Version>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/NuclearPowered/Reactor.OxygenFilter</RepositoryUrl>
<PackageLicenseExpression>LGPL-3.0-or-later</PackageLicenseExpression>
Expand All @@ -31,7 +31,7 @@

<Target Name="PackTaskDependencies" BeforeTargets="GenerateNuspec">
<ItemGroup>
<_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">
<PackagePath>lib%(RecursiveDir)</PackagePath>
<Visible>false</Visible>
<BuildAction>Content</BuildAction>
Expand Down

0 comments on commit 36dc6bc

Please sign in to comment.