question

AndrewBroughton-9811 avatar image
0 Votes"
AndrewBroughton-9811 asked AndrewBroughton-9811 edited

Blazor server desktop MacOS

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!

dotnet-aspnet-core-blazor
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndrewBroughton-9811 avatar image
0 Votes"
AndrewBroughton-9811 answered AndrewBroughton-9811 edited

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://docs.microsoft.com/en-us/answers/questions/533627/blazor-server-demo-app-doesn39t-load-css-on-macos.html

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered

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.






5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndrewBroughton-9811 avatar image
0 Votes"
AndrewBroughton-9811 answered Bruce-SqlWork edited

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.

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

The Vs2019 publish focus on deploying to a web server, not a desktop. You can do a folder publish with vs.

Your blazor server app is a web server. It will not start the browser when you run it. You need to create a new program or shell script that starts the blazor server, and opens the browser.

You can package all this as an OS X application bundle. I’d probably use Xcode to create this utility (only a couple lines) and add the blazor app to its bundle. or build a package.

0 Votes 0 ·
AndrewBroughton-9811 avatar image
0 Votes"
AndrewBroughton-9811 answered

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!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Bruce-SqlWork avatar image
0 Votes"
Bruce-SqlWork answered Bruce-SqlWork edited
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.