✅ Having trouble compiling a C# 11 file (not mine) on Mac
Using
mcs
throws a whole bunch of compiler errors since it doesn't support C# 11 syntax yet.
Using dotnet build
results in this error:
39 Replies
MCS will never support C# 7, let alone C# 11
Then what do I do
You figure out what you've configured wrong with modern .NET
I don't even know how to configure .NET
I have no idea what I'm doing I just want to run someone else's code
Well, what you've said so far isn't really enough to help you. Presumably you're on either mac or linux, since you tried to use mcs, but how did you install .NET? How did you get this person's code? How are you trying to build it?
I'm on mac as I said in the title
Specifically a 2020 Mac M1 running Ventura 13.2.1
I installed .NET 8.0 from here: https://dotnet.microsoft.com/en-us/download/dotnet/8.0
Microsoft
Download .NET 8.0 (Linux, macOS, and Windows)
.NET 8.0 downloads for Linux, macOS, and Windows. .NET is a free, cross-platform, open-source developer platform for building many different types of applications.
I got the person's code from GitHub
I am trying to build it using
dotnet build
What github?
Do I need to share the exact repo?
I mean, that would be the fastest way for someone to help you...
Even if I change the
Program.cs
file to just Console.WriteLine("Hello World");
, the same issue persists
That means it has nothing to do with the code, and therefore there is no point in sharing the codeUnless it has something to do with the project file 🙂
Go into another directory entirely. Run
dotnet new console --name Test && cd Test && dotnet run
Not a nested directory, to be clear; somewhere completely separate
I would probably just do it from ~
Did run work too?
Yes
Alright. Then my best guess is that you ran something as
sudo
in the other project, and permissions are messed up in various locationsHold on
dotnet new console --name Test && cd Test && dotnet build && dotnet run
still results in Hello World even if I change the code of Program.cs
Of what Program.cs?
Because frankly, what you're describing there is far easier to attribute to you doing something wrong than the laws of the universe having broken 🙂
Obviously I'm doing something wrong
I just don't know what
That's why I asked for help
.
The one in my current dir
Wait, the console command doesn't copy over the same files to another dir, it just creates default ones?
Yes, that creates a new project from the standard template. That's why I asked which Program.cs 😄
My goal with that command was to troubleshoot your base install of
dotnet
Oh ok
It succeeded, so we know that at least the minimal example works
And any access denied errors are likely specific to the project files that you've cloned: either one of the scripts you ran when trying to build it ran something as
sudo
and messed up the directory, or the files have some weird permissions checked into the repoWould a chmod 777 fix all the permissions?
I would guess not.
sudo
is the more likely thing
And it may be that something under ~/.nuget
is also owned by the wrong thing now too because of it
I'm going to bed now. Good luck figuring it outHonestly it's way easier to brew .net for future reference
Ok
However, installation from homebrew is not considered officially supported I think, as you need to follow a Microsoft Learn article 👀
I suppose, maybe MS should create homebrew package.
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
Homebrew just uses the official package iirc
Then maybe find a way to update the official doc to include that 😅
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
I mean it's the cask or formula or whatever is maintained by someone other than MS even though it uses the official package.
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View