Blazor server desktop MacOS

Andrew Broughton 96 Reputation points
2021-08-04T17:46:43.72+00:00

How does one create a Blazor Server app with the server running on a MacOS desktop.
It does this automagically within VS, how do I create a redistributable app that a person can install on a MacOS, Windows or Linux Desktop?

Not talking about a server-based Blazor app on the Web, but one that runs on a local desktop. Not interested in WebAssembly either. Like I say, this is possible within the VS environment, but publishing the app does not include the required server software that's needed.

I see plenty of stuff about IIS, but I want to build a x-plat version that runs on MacOS, Windows, Linux, etc.

thank you!

Blazor
Blazor
A free and open-source web framework that enables developers to create web apps using C# and HTML being developed by Microsoft.
1,579 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andrew Broughton 96 Reputation points
    2021-08-31T16:11:09.447+00:00

    Looks like the latest build fixed some of the build issues. In VS2022 I can now build/publish a Blazor Server app for Windows and MacOS complete.

    Except of course for a bug on MacOS that I cannot find any information regarding...
    https://learn.microsoft.com/en-us/answers/questions/533627/blazor-server-demo-app-doesn39t-load-css-on-macos.html

    0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Bruce (SqlWork.com) 65,311 Reputation points
    2021-08-04T20:55:38.88+00:00

    a Blazor server app on MacOs is just a command line utility. build with

    dotnet publish -r osx-x64

    this will create folder with a command line app, and website folders. if you don't want the user to install the dotnet runtime, publish a self contained.

    you can copy this folder to a mac or linux, and run the application, then in browser localhost:<port>.

    now you just need to decide how to deploy to the application. VS only supports folder copy to webserver or file location.

    For mac, you can also build a bundle for the app (on mac a bundle is a self contained folder that is a single file) and just copied to the users computer. you can make a dmg, that they download, and mount. also home-brew is an option.

    For Linux, there are two install system based on the linux branch. apt-get or yum. You can probably find 3rd party or open source help to create these packages.

    once you have deployed to the users computer, how will they run the app?

    on a mac you can use launchctl as a startup application, so it is always running. then the uses just accesses with the browser. or you could create a script that starts the app if not running, then open in the browser.

    the steps are similar for linux, except you use systemctl instead of launchctl (MacOs is berkley unix).

    if you want to use ngnix or apache, you configure these are reverse proxies to the running app.

    0 comments No comments

  2. Andrew Broughton 96 Reputation points
    2021-08-05T02:19:43.65+00:00

    Thank you for your reply! I'll give that a try.

    So, why does the "publish" command in vs2019 not do what "dotnet publish -r osx-x64" does?
    How do I publish "self contained" as you suggest?

    "How will they run the app" you ask?
    I want the user to get the file or archive from me, double-click it (or extract it, then double-click), and it starts the server and opens the webpage, just like any commercial app. I can build it into a dmg if need be.


  3. Andrew Broughton 96 Reputation points
    2021-08-05T03:45:29.57+00:00

    Ok, that seems to work. I wonder why that can't be done within vs2019!

    That is a TON of libraries. Yikes!

    Thank you for your help!

    0 comments No comments

  4. Bruce (SqlWork.com) 65,311 Reputation points
    2021-08-05T15:20:13.343+00:00
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.