Improve OSX non self contained mode wrt name/folder clashing
This commit is contained in:
parent
2b4b6353c2
commit
6a34fb71e0
2 changed files with 18 additions and 25 deletions
2
TShockLauncher/TShock.sh
Executable file
2
TShockLauncher/TShock.sh
Executable file
|
|
@ -0,0 +1,2 @@
|
||||||
|
#!/bin/bash
|
||||||
|
./bin/TShock.Run
|
||||||
|
|
@ -5,8 +5,11 @@
|
||||||
<TargetFramework>net6.0</TargetFramework>
|
<TargetFramework>net6.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<AssemblyName>TShock</AssemblyName>
|
<AssemblyName Condition="$([MSBuild]::IsOSPlatform('Windows'))">TShock</AssemblyName>
|
||||||
|
<AssemblyName Condition="$([MSBuild]::IsOSPlatform('Windows')) == false">TShock.Run</AssemblyName>
|
||||||
|
<RunPostBuildEvent>Always</RunPostBuildEvent>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\TerrariaServerAPI\TerrariaServerAPI\TerrariaServerAPI.csproj" />
|
<ProjectReference Include="..\TerrariaServerAPI\TerrariaServerAPI\TerrariaServerAPI.csproj" />
|
||||||
<ProjectReference Include="..\TShockAPI\TShockAPI.csproj">
|
<ProjectReference Include="..\TShockAPI\TShockAPI.csproj">
|
||||||
|
|
@ -26,9 +29,14 @@
|
||||||
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.115.5" />
|
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.115.5" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<None Update="TShock.sh">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
|
</ItemGroup>
|
||||||
<Target Name="MoveToBinFolderDebug" AfterTargets="FinalCleanup;PostBuildEvent">
|
<Target Name="MoveToBinFolderDebug" AfterTargets="FinalCleanup;PostBuildEvent">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<MoveBinariesForDebug Include="$(TargetDir)*" Exclude="$(TargetDir)\TShock*" />
|
<MoveBinariesForDebug Include="$(TargetDir)*" Exclude="$(TargetDir)TShock.Run*" />
|
||||||
<TShockPluginFiles Include="$(ProjectDir)../TShockAPI/bin/$(Configuration)/$(TargetFramework)/TShockAPI*" />
|
<TShockPluginFiles Include="$(ProjectDir)../TShockAPI/bin/$(Configuration)/$(TargetFramework)/TShockAPI*" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Move SourceFiles="@(MoveBinariesForDebug)" DestinationFolder="$(TargetDir)bin" ContinueOnError="true" />
|
<Move SourceFiles="@(MoveBinariesForDebug)" DestinationFolder="$(TargetDir)bin" ContinueOnError="true" />
|
||||||
|
|
@ -44,10 +52,7 @@
|
||||||
<Copy SourceFiles="@(TShockPluginFilesForPublish)" DestinationFolder="$(PublishDir)ServerPlugins" ContinueOnError="true" />
|
<Copy SourceFiles="@(TShockPluginFilesForPublish)" DestinationFolder="$(PublishDir)ServerPlugins" ContinueOnError="true" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<UsingTask
|
<UsingTask TaskName="PatchAppHost" TaskFactory="RoslynCodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll">
|
||||||
TaskName="PatchAppHost"
|
|
||||||
TaskFactory="RoslynCodeTaskFactory"
|
|
||||||
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
|
|
||||||
<ParameterGroup>
|
<ParameterGroup>
|
||||||
<HostExe ParameterType="System.String" Required="true" />
|
<HostExe ParameterType="System.String" Required="true" />
|
||||||
</ParameterGroup>
|
</ParameterGroup>
|
||||||
|
|
@ -65,14 +70,14 @@
|
||||||
var contents = File.ReadAllBytes(HostExe);
|
var contents = File.ReadAllBytes(HostExe);
|
||||||
|
|
||||||
var matches = 0;
|
var matches = 0;
|
||||||
var offset = Array.FindIndex(contents, (b) => {
|
var offset = Array.FindIndex(contents, (b) => {
|
||||||
matches = (b == find[matches]) ? matches + 1 : 0;
|
matches = (b == find[matches]) ? matches + 1 : 0;
|
||||||
return matches == find.Length;
|
return matches == find.Length;
|
||||||
});
|
});
|
||||||
if (offset > -1) offset -= find.Length - 1;
|
if (offset > -1) offset -= find.Length - 1;
|
||||||
|
|
||||||
var x = 0;
|
var x = 0;
|
||||||
Array.ForEach(replace, _ => { contents[offset + x] = replace[x++]; });
|
Array.ForEach(replace, _ => { contents[offset + x] = replace[x++]; });
|
||||||
|
|
||||||
File.WriteAllBytes(HostExe, contents);
|
File.WriteAllBytes(HostExe, contents);
|
||||||
</Code>
|
</Code>
|
||||||
|
|
@ -84,22 +89,8 @@
|
||||||
<Message Text="Patched TShock.exe host for ./bin redirect" Importance="High" />
|
<Message Text="Patched TShock.exe host for ./bin redirect" Importance="High" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<UsingTask
|
|
||||||
TaskName="CreateOsxLauncher"
|
|
||||||
TaskFactory="RoslynCodeTaskFactory"
|
|
||||||
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.Core.dll" >
|
|
||||||
<ParameterGroup>
|
|
||||||
<OutPath ParameterType="System.String" Required="true" />
|
|
||||||
</ParameterGroup>
|
|
||||||
<Task>
|
|
||||||
<Code Type="Fragment" Language="cs">
|
|
||||||
File.WriteAllText(Path.Combine(OutPath, "TShock.exe"), "#!/bin/bash\n./bin/TShock");
|
|
||||||
</Code>
|
|
||||||
</Task>
|
|
||||||
</UsingTask>
|
|
||||||
|
|
||||||
<Target Name="CreateOsxLauncherAfterPublish" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)' == 'osx-x64'">
|
<Target Name="CreateOsxLauncherAfterPublish" AfterTargets="Publish" Condition="'$(RuntimeIdentifier)' == 'osx-x64'">
|
||||||
<CreateOsxLauncher OutPath="$(PublishDir)" />
|
<Move SourceFiles="$(PublishDir)bin/TShock.sh" DestinationFolder="$(PublishDir)" ContinueOnError="true" />
|
||||||
<Message Text="Run the launcher with chmod u+x TShock.exe && ./TShock.exe" Importance="High" />
|
<!-- <Message Text="Run the launcher with chmod u+x TShock.exe && ./TShock.exe" Importance="High" /> -->
|
||||||
</Target>
|
</Target>
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue