✅ How to share my C# console application with MacOS friends?
hello. i made a very very basic c# console application game using jetbrains rider
i want to share my game that i've made with my friends
my teacher suggested to share the .exe file to my friends via a google drive link, and this works brilliantly for some of my friends
however, those who use MacOS cannot run this
how can i share my game to my MacOS friends
i want it to be as simple as possible for them, so they just click a file and boom it works, just like it is with sharing the .exe file
(edit, im a beginner and im clueless about a lot of programming stuff. i looked at docker and it was difficult to understand/get to work)
101 Replies
You'll want to publish your app as a self-contained single file application, with a MacOS RID
$singlefile
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true
Use of -p:PublishSingleFile=true
implies --self-contained true
. Add --self-contained false
to publish as runtime-dependent.
-r RID
and -p:PublishSingleFile=true
can be moved to .csproj as the following properties:but to target multiple RIDs, you have to use dotnet publish
with the -r
option for each RID.
You can also add -p:IncludeNativeLibrariesForSelfExtract=true
to include native libraries (like Common Language Runtime dlls) in the output executable.
You might want to instead publish your application compiled Ahead Of Time to native code, see $nativeaot for examples.
Single file publishing | Runtime Identifier (RID) catalog | dotnet publish
sorry i'm completely lost, please can you break that down a bit for me
thanks Pobiega
Well, once your app is done and you want to "release" it, you publish it
dotnet publish -c Release
will do that, but you want it to work on a mac
so we need to tell the publisher to turn it into a mac executable
we can do that with -r osx-x64
(if they are using "normal" macs), or -r osx-arm64
for M1s etcright now i like how whenever i build my game, the .exe file is updated
The game is still a work in progress and i've just began understand OOP so im adding in new features etc
im making 3-4 new things / fixing old things per day, ideally i don't want to be doing something long every time i change something and want to 'publish' it
I wouldn't say executing a single command is "doing something long"
well you will need to republish every time
but it is, as zzz said, a single command
yeah, youre right; as i learn it'll become very easy
i understand so far
so i go into terminal within my IDE, type out
dotnet publish -c Release -r osx-x64
well, sorta
you also need the other stuff from the tag I invoked
dotnet publish -c Release -r osx-x64 -p:PublishSingleFile=true
what goes in the <runtime identifier>?
what does runtime-dependent mean?
and again, if they are on... what do Mac call it, Silicone? Silica? CPUs, they need another RID
apple silicon, yes
runtime identifier == RID
a modern windows PC is most likely
win-x64
macs are different from windows, they use different formats. the stuff after the dash is the processor architecturefor windows PCs im happy to continue just sharing the google drive link because..well it works so far, but im willing to learn regardless
you can publish for multiple RIDs if needed
meaning two formats, for M1 and intel-based macs
yes
so, to run a .NET project, you must have the .NET runtime
i feel incompetend but pasting that into terminal gives:
my game is using the .NET frameowrk v4.8
oh
Oof
you're fucked then
No Mac for you
no mac for you indeed
.NET Framework is strictly Windows-only
and why's that?
uhoh
.NET fx is old and dead
it died in 2016
Only since .NET Core did it become cross-platform
i can copy pasta my code into a new form of project format?
It's Winforms?
Then no
Winforms is Windows-only
you said it was a console app no?
Windows Forms
if its a console app, you can migrate
i use jetbrains rider for macos
here's the settings whenever i create a new solution
yeah you picked the wrong thing
no worries, i can copy pasta or migrate it over right?
I'm on Rider EAP so my new solution window is different...
lets see if I have non-EAP installed
You want the Console project without
.NET Framework
parti feel like im meant to use one of these
there
you want to use the ones from the
.NET / .NET Core
section
pretend .NET framework doesnt existi feel like im making progress
thanks
Yeah, this will do the trick
done, thank you
Just check the
Create GIT repository
box while you're at itso create a new solution there, copy pasta everything over, then we're chilling?
Yeah
kinda
Should work
you might need to tweak a few things, but mostly it should work
also, you WILL need to change how you "publish" for windows
yup my current project is in github (slightly concerned about creating a new project meaning losing all commit history etc. but thats for later)
if you care then here's the link: https://github.com/aadityakalwani/Gold_Diggerzz
GitHub
GitHub - aadityakalwani/Gold_Diggerzz: a digging simulator game
a digging simulator game. Contribute to aadityakalwani/Gold_Diggerzz development by creating an account on GitHub.
the modern .NET runtime isnt pre-installed on all windows computers
so you'll need to do the
dotnet publish -r win-x64
thingso one for windows, one for intel macs and one for apple silicon macs, sure thats only 3 commands i'll learn that
its the same command, just with 3 different RIDs
on a side note is there a way i can migrate to the .net core and run away from the .net framework without losing my current github history and stuff?
You can always just make a quick script with something like Taskfile or Make, so you would just call
task publish
and it runs all 3 commands
There's an Upgrade Assistant
And a documentation page on migrating an existing Fx project to .NETyeah you can just replace your .csproj file and some other stuff really
either manually or via the upgrade assistant
remove one file, add in the new one
...but this will lose commit history on the file i just deleted?
(i care about commit history because it shows my learning well imo)
no
well, yes
or not
:p
bruh
if you name the file the same, its fine
they should both be .csproj anyways
it will just be a drastic change
wdym?
well, the old csproj files had a different structure
so "all of the file" might change
or its not that old and then it will be a very small change
i'll move all my classes into one file before to simplify it
you dont need to
modern .NET apps dont list all cs files
they are folder based
thank god
so create a new file with the same name (using the .net core nor .net framework)
delete the old .csproj
add in the new one
still chilling?
probably better to use the upgrade assistant
safer atleast
just randomly replacing files then asking us if its fine is... uh... not a good idea
if you showed me the old and the new file, maybe
but at that point.. just use the upgrade assistant
(apologising in advance but im equally lost trying this)
learn to help yourself
its the single most important skill
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
i've done this but..what does this actually do? it seems its now a net 8.0 which is nice
but i dont think this 'converted' my .net framework v4.8 to .net core v8.0?
Does it work?
wdym? the code runs, but i dont think thats what you mean
currently retrying to do this
If it runs, then congratulations, you succesfully updated to .NET 8
whoa
that simple?
If the code is simple enough, yeah
so im assuming migration assitanct just updates the .csproj (or at least in this case) for me
For bigger and more complex projects it does more
so the previous 'dotnet public -c' etc. should work now?
Yep
hey thanks for your help
trying rn
got somewhere and now ive got stuck at an error saying "reference assemblies for .net framework v4.8 were not found. isntall them with this link or retarget your application"
SUCCESS
by that, i mean running:
dotnet publish -c Release -r osx-arm64 -p:PublishSingleFile=true
didn't throw an error and said 'restored'
its looking good, testing with a friend now to see if they can load it up (it works in my terminal)
Sorry @Aadi your message contained blocked content and has been removed!
Sorry @Aadi your message contained blocked content and has been removed!
sending this over via an online sharing platform owned by alphabet inc doesnt work
however through a macbook-to-macbook system called 'air' followed by 'drop' does make it work
but i had to install .net on the other device
is the ultimate solution to just get docker / dockerfile?
You would need Docker installed, then 😛
And the whole overhead and complexity of it
$singlefile
dotnet publish -c Release -r <runtime identifier> -p:PublishSingleFile=true
Use of -p:PublishSingleFile=true
implies --self-contained true
. Add --self-contained false
to publish as runtime-dependent.
-r RID
and -p:PublishSingleFile=true
can be moved to .csproj as the following properties:but to target multiple RIDs, you have to use dotnet publish
with the -r
option for each RID.
You can also add -p:IncludeNativeLibrariesForSelfExtract=true
to include native libraries (like Common Language Runtime dlls) in the output executable.
You might want to instead publish your application compiled Ahead Of Time to native code, see $nativeaot for examples.
Single file publishing | Runtime Identifier (RID) catalog | dotnet publish
Ah
This is your debug artifacts
Look intio the release folder
nooooo im an idiot lol
before when sharing the .exe file it was in bin -> debug
so i assumed the same to be true
would the other device need to have .net installed?
before sending just that file didnt work, it said it couldnt find the .dll file so i had to send over the whole folder
If it's self-contained, no
"this file is damaged" error when its tried to run
google's file sharing called d r i v e doesnt seem to let it download
generally speaking, how does the majority share their console apps with friends?
do they do what i did and then from within the release folder, they share across the unix executable file and then run it like that?
or is it like 99% docker
or do people generally not share programs like this
++ ive spent some time trying to learn docker and so far i havent got a successful container and it seems like some more work, but if i have / if its the best option then i will
Docker is more work for you, but also for whoever wants to run it
Far as sharing the executable... I usually just use Github releases
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
https://drive.google.com/drive/folders/1SaYKFXTkizdvE6w_939p4VEB-2eJRy5q?usp=sharing
i believe i've done it now and with the initial testing it seems to work!
Pobiega, thanks for the initial 'dotnet publish -c Release -r win-x64 -p:PublishSingleFile=true ' instructions, they worked brilliantly
ZZZ, thanks for general help in...pretty much all of it lol
TeBeCo, thanks for the help in updating the .csproj and also for the -o associated with dotnet publish
the above link now works, shared it just in case anyone's curious
Thank you all once more 🙏
Unknown User•10mo ago
Message Not Public
Sign In & Join Server To View
fair enough 🫡