Configure Rider to build for multiple platforms

Hello everyone,

I'd like to clear up some questions about building applications in JetBrains Rider.

1. Building a project
First of all, I'd want to know if simply running the solution (CTRL+F5 or the green Play button) while my Release configuration is selected (which I'll show below) is enough to properly build my project, so it produces all the necessary material for a functioning program. As far as I've noticed, this seems to build the project fine, I just want to verify.

2. Build for multiple platforms
My main issue is that my goal is to compile/build my .NET 5 project for Windows, Linux and MacOS, preferably at the same time. Right now, I can only find a Unix executable file amongst all necessary .dll files, while it's important to mention that I'm using JetBrains Rider on Linux (Ubuntu-based distribution).
So, after running the project with my Release configuration, which is configured as follows at the bottom, I want to have the built version of my .NET application as a separate folder for Windows, Linux and MacOS to provide them separately as executable applications. They should be executable out of the box then if I'm understanding right.

3. MacOS and Linux interchangeable?
I haven't built .NET applications for MacOS yet, but am I right if I say that the build for Linux and MacOS doesn't differ, so I can use the same one? In that case, I'd only need a build for Windows and one for Unix-like Operating Systems. If that isn't so, I'd need 3 separate builds.

Below you can find an image of how my Release configuration is configured right now and I can additionally say that it's also set up to Build and Deploy. My problem is that I'm trying to find out how to configure the build settings in Rider to build for Windows, Linux and MacOS. Sure, I could create another configuration for Windows separately, but I wasn't able to find a configuration for the platform, apart from the CPU architecture.

I'd be happy if someone could help me to understand this entire process with JetBrains Rider.
Thank you very much!

7 comments
Comment actions Permalink

As an addition, I just noticed that there is actually a .exe file in the Debug folder, but none in the Release folder. The "Exe Path" of the solution configuration is set to the Debug folder, but shouldn't it be set to Release by default and can there be a .exe file per configuration (Debug, Release)?

I would still be happy if someone could clarify to me how compiling/building works with JetBrains Rider, especially regarding cross-platform building. How does all that work and is it a full replacement for `dotnet` commands? Primarily, is it enough to fully compile/build a usable application (for multiple platforms)? I guess it is, but I want to be 100% sure.

Thank you very much already in advance!

1
Comment actions Permalink

Hi,

You should be able to run the same .dll on Windows as well.

0
Comment actions Permalink

Sofia Byzova Thank you very much for your answer, I greatly appreciate it.

Do you mean that the .exe file that's being built into the Debug folder can be used as an accurate executable file on Windows? I assume that is so, I just want to make sure that I'm really doing it the right way.
Also, would that mean I can freely change the `EXE Path` to the Release folder or is there even a way to produce two of them, one for Debug and one for Release, as it's happening with the Unix executable file?

I'm not 100% sure about this entire workflow, so there are some questions left. Thank you again for your answer.

0
Comment actions Permalink

Hello Duck,

Does the `Run` causes project build?
Yes, by default the project is being built before `Run` via green triangle. Run configuration has a default `before launch` step set: `Build`. You can disable it from run configuration settings.

Debug, Release folders
The binaries are being generated in the appropriate folders when the project is built. When you build your solution with `Debug | Any CPU` build configuration, the files are being generated under the `Debug` folder. The same is similar for `Release | Any CPU` build configuration.

MacOS and Linux interchangeable?
The executable itself is not cross-platform. The executable that was published targetting `osx-64` can't be run on Linux, but the .dll file is cross-platform and might be run via `dotnet {file}.dll`. If the proper .Net runtime is installed on the target machine, the program should start. 
You can find more information about publishing from [this](https://docs.microsoft.com/en-us/dotnet/core/deploying/) page.

Build for multiple platforms
There is a way to configure the behavior you desire. Please follow the below steps for that:

  • Open `Run | Edit configurations`
  • Press `+`, select `Publish to folder`;
  • Set `Target runtime` to required OS; (ex. win-x64)
  • Set `Target location` - the folder where you want the output to be generated;
  • Set `Configuration` to `Release | Any CPU`;
  • There is an optional ability to `Produce single file`;
  • Name the configuration somehow (ex. PublishWin64);
  • Create two more `Publish to folder` run configurations in the same way;
  • Create a `Compound` run configuration, name it somehow (ex. MultiPublish);
  • Add the recently created `PublishWin`, `PublishLinux`, `PublishOSx` to the list;

Now you can run the `MultiPublish` run configuration, so the executable files for platforms configured will be generated in the folders set; 

Should you have any other questions or difficulties, please let me know.

0
Comment actions Permalink

Hello Dmitry Kazantsev,

I really appreciate your explanation, it helped me a lot. I managed to set the build configurations up and it works exactly as expected. Now I have three folders for three platforms and I can run the application without any problems, at least one of them.

There is only one little issue, where the "MultiPublish" configuration only seems to build the Windows configuration. Linux (x64) and OSX (x64) fail. Instead, the output folder of those two only contains a "ref" folder, which is empty. In the process of publishing, an error message appears (twice), but only for a fraction of a second, so I'm not able to read it and I can't find it later anymore.
If I build them separately however (publish configurations separately, instead of using the "MultiPublish" compound), it works fine. That's not much of a problem, although it would be convenient to build it for all three with only one click. It's all set up correctly.

 

Thank you again for your help, I appreciate it!

0
Comment actions Permalink

Hello Duck,

Apologies for not responding earlier.
It seems like a bug. I have raised this issue to our tracker. We would appreciate it if you could upvote the issue to demonstrate additional interest.

Should you have any other questions or difficulties, please let me know.

Have a great day!

1
Comment actions Permalink

Thank you very much for your effort. I updvoted the issue, thank you for letting me know.

 

Have a nice day!

0

Please sign in to leave a comment.