-
-
Notifications
You must be signed in to change notification settings - Fork 52
Compiling on linux for Windows/MacOS/Linux? #4
Comments
You can use .NET Core with Visual Studio to build the SelfPatcherConsoleApp and SimplePatchToolConsoleApp projects. With Mono, you should be able to compile the SelfPatcherWinForms project, as well. But you'll have to generate the MacOS executables on a MacOS and Linux executables on a Linux. It is also possible to create your own self patcher executable in e.g. Objective-C or C/C++. You can do so by examining SelfPatcher.cs and translating it to the language of your choice. P.S. If you'd like to create a fresh new .NET Core project and use it to compile SelfPatcherConsoleApp, you just need to copy these 3 C# files to your project and then build the project: |
So just these 3 files are enough to compile actual SelfPatcher.exe? Does it depend on any specific .NET framework? Or then it's just up to me? That might work for creating solution that is working anywhere dotnet is installed. I tried using Rewriting it in some other language seems kind of promising, there's not that much logic I guess. Would be nice to see a SelfPatcher that works/compiles on any platform. |
Yes, once you build a SelfPatcher with these three .cs files using .NET Core, it is supposed to work on devices with .NET Core Runtime installed. That's the thing about cross-platform C# development: your target platform needs to have certain components installed in order to run the application. But since SimplePatchTool itself is written in C#, the app that integrates SimplePatchTool will also depend on these components to work so if the app can work on a particular OS, so should the self patcher be. I'm not sure whether or not these components come pre-installed in MacOS or popular Linux distributions because I haven't tested SimplePatchTool on these platforms myself. You can google "net core mac prerequisites" or "mono mac os prerequisites" to learn more. |
I'm sorry for troubling you with all of this. I'm just trying to understand how this things work so we can use Patcher on other platforms than Windows which seems possible but I'm just missing few steps. |
Of course! I'm very interested in seeing the results of your attempts so please keep me updated! |
Will do. One question - what this Cryptography.XML is used for? Is it something used to securely send files over the net? Or nothing like that? |
It is used in the optional SimplePatchToolSecurity module to sign&verify XML files for increased security against man-in-the-middle attacks: https://github.com/yasirkula/SimplePatchTool/blob/master/SimplePatchToolSecurity/XMLSigner.cs It requires this NuGet package for .NET Standard 2.0 compatibility: https://www.nuget.org/packages/System.Security.Cryptography.Xml/ |
Ok, I'd like to have that working as well if possible. I guess I'll have to analyse the structure in depth to understand what is what. |
You don't need to know most of the classes, actually. I'd recommend you to follow the instructions on the Wiki, the important classes are already described in detail there: https://github.com/yasirkula/SimplePatchTool/wiki |
Some progress update - I've decided to just use the project as is and use mono to compile it on Linux/MacOS. It was fairly straightforward. And now a question - how would you approach creating update tree if our App had I was thinking of something like: I wonder if this could overwrite in any way the Output folder and render it useless. I guess I won't know until I find out. Unless there is a way to specify Output folder location and I just missed it. |
It is possible to completely customize the patch creation process using the legacy method while creating patches. However, I think it would be unnecessary: I'm assuming the Windows/Linux/OSX folders are SimplePatchTool-projects and P.S. While using projects, you can use the P.P.S. While searching for System.XML in SimplePatchTool, I could find only System.Xml. Can you remember which System.XML's you've fixed? |
diff --git a/SimplePatchToolCore/SimplePatchToolCore.csproj b/SimplePatchToolCore/SimplePatchToolCore.csproj
diff --git a/SimplePatchToolSecurity/SimplePatchToolSecurity.csproj b/SimplePatchToolSecurity/SimplePatchToolSecurity.cspr
The above are the 2 places (click on them to expand) where I found Also thanks for all the help, I've been able to figure it out. Next thing left is testing on these platforms if things actually work. |
Trying to do something similar here, but I'm looking to use the Unity simple patch tool to make building for Windows, Linux, and MacOS a breeze (rather than building a Windows form using Mono). That and I already have CICD/Jenkins scripts around building multi targeted Unity applications. At first I converted all of the libraries to .NET standard and all of the console apps to .NET Core. However, to use .NET standard in Unity I had to copy over a lot more dependencies into my Unity project. Then I created a side project to build the SimplePatchToolCore library in .NET Framework so that I wouldn't have to bundle all of those .NET standard DLLs. Finally, I familiarized myself with Multi Targeted builds from a single project (something I had never done before) and updated ALL libraries to build DLLs for the following targets:
And updated ALL console apps to build executables for the following targets:
Note that I left the WinForm projects pointing to .NET Framework 3.5 for now. Once .NET Core 3.0 comes out, I plan on updating the Form projects to build all 3 targets as well. One thing that was cool.. I was able to get the SelfPatcher to work on MacOS after some minor tweaks to how you're launching the SelfPatcher console app (given that you need to use My next steps are to bake the few differences for Unix based systems vs Windows sytems directly into the CSProjs directly using #if NETCORE / I got a bit giddy when I saw that .NET Core 3 will support Windows Forms, but it looks like they won't be cross platform :( Note that you can find my changes here: I'm working on the Unix support now -- but if you're interested I'd love to submit a PR against your repo once I'm done. If we move some of wiki docs directly to the README I could then update the instructions on how to build a patch, create a project, etc. for .NET Core. This would help keep the instructions versioned with changes to the repository itself. Not a big deal -- just something to consider for contributions. |
Just realized that furai is trying to compile on Linux. I guess this is quite a bit different since I'm more trying to build a cross-platform Unity patcher on Windows. I assume this might still make the process of getting a Linux build server up quicker as most pieces are being built in .NET standard/.NET core with my changes. I've never tried to open up a visual studio SLN in MacOS or Linux so I'm really not sure if they'll freak out from having .NET 3.5/4.6.1 targets -- or if they will just skip those and build the .NET Standard / .NET Core libraries/console apps. |
So I was able to get a self-contained SelfPatcher created using the dotnet publish command with a specific runtime:
To get around the Unity subdirectory issue (for macos the directory for the self patcher will launch in .app/Contents/MacOs where it needs to launch in .app/) I had to make this modification: Which then allowed me to add this in the Unity MultiGame demo script:
The only problem I'm having now.. after the SelfPatcher is downloaded for the first time I will always need to If you guys have any ideas on how to make sure the downloaded file can be executed on a Unix based system.. let me know. Seems to be the last piece for me to have this all working cross-platform. |
Well, not sure whats causing the issue.. but I was able to add a workaround in the Unity client:
|
The permissions problem is due to the fact that you probably ship it from Windows. Windows has different permission system than Linux and it's really hard to work around that. Best is to apply fix permissions in CD after you upload the file to Linux host. As to my original issue - I've managed to build it on each platform (Linux/MacOS/Windows respectively) using mono 6.0 and msbuild. |
Hey!
I'm right now stuck with trying to compile SelfPatcher on Linux (Ubuntu 19.04). Is this even possible?
Can I compile it using RIDs so the resulting executables/libraries are working on different platforms like Windows/MacOS/Linux?
I've been trying just to compile the Console App under linux and i can't seem to be able to make it work.
I'm sorry but I'm really new to the topic and I'm not sure if I'm even trying to do the right thing.
EDIT: This was intended to be used later on by my colleague in his Unity game project. If someone was able to just provide me with compiled versions of the latest Patcher version for each platform respectively (MacOS/Linux/Windows) then that would help a lot.
Any instructions and help are highly welcome!
Cheers,
Furai
The text was updated successfully, but these errors were encountered: