C
C#10mo ago
JaxOnThat

❔ Anyone here know Makefiles?

Hi. I need to install Newtonsoft JSON with a Makefile for a University Project. And once I do that, how do I make sure my code will be able to access it?
22 Replies
JaxOnThat
JaxOnThat10mo ago
Current Makefile:
.PHONY: client.cs

all: run

client.exe: client.cs
@apt-get update && apt-get install -y mono-complete
@mcs client.cs

clean:
@rm -f client.exe

run: client.exe
@mono client.exe
.PHONY: client.cs

all: run

client.exe: client.cs
@apt-get update && apt-get install -y mono-complete
@mcs client.cs

clean:
@rm -f client.exe

run: client.exe
@mono client.exe
jcotton42
jcotton4210mo ago
do you have to use make and mono? .NET has a project system (also, why on earth is your Makefile calling apt?) @JaxOnThat in modern .NET you could use the built in System.Text.Json and if you still needed NewtonSoft, would just be dotnet add package Newtonsoft.Json in the same dir as the csproj then builds would pull it from nuget automatically
jcotton42
jcotton4210mo ago
Install .NET on Linux distributions - .NET
Learn about how to install .NET on Linux. .NET is not only available at package.microsoft.com, but also the official package archives for various Linux distributions.
jcotton42
jcotton4210mo ago
if you must use mono, then you should still be able to use nuget but please use the project system, don't use make of all things
JaxOnThat
JaxOnThat10mo ago
It's for a University Project, if I could avoid Make I absolutely would 😅 🔫 as for why I need Mono, it's getting run on Linux
Anchy
Anchy10mo ago
if you use modern .NET it will run on linux
JaxOnThat
JaxOnThat10mo ago
i'm guessing that's not what i'm doing?
Anchy
Anchy10mo ago
i dont know
Angius
Angius10mo ago
Mono is not .NET It's a sort of a demented port of the old .NET Framework
JaxOnThat
JaxOnThat10mo ago
ah
Angius
Angius10mo ago
.NET works on Linux out of the box
JaxOnThat
JaxOnThat10mo ago
how do i change it to use .net
Angius
Angius10mo ago
No makefiles or anything else required Just get the .NET 7 SDK and you're set
JaxOnThat
JaxOnThat10mo ago
I cannot abandon the Makefile, it is part of the assignment parameters 😦 and also i cannot install things on the machine they will run this on outside of the makefile
Angius
Angius10mo ago
.NET can depoloy single-file executables They bundle the runtime and everything else And trim the unused parts So you end up with just a single runnable file
JaxOnThat
JaxOnThat10mo ago
is there a way i can activate it from a Makefile?
Angius
Angius10mo ago
Idk maybe? Just have the makefile execute the $singlefile command lol
MODiX
MODiX10mo ago
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:
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<RuntimeIdentifier>RID</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
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. https://docs.microsoft.com/en-us/dotnet/core/deploying/single-file https://docs.microsoft.com/en-us/dotnet/core/rid-catalog https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-publish
Create a single file for application deployment - .NET
Learn what single file application is and why you should consider using this application deployment model.
.NET Runtime Identifier (RID) catalog - .NET
Learn about the runtime identifier (RID) and how RIDs are used in .NET.
Angius
Angius10mo ago
And have it install the SDK I guess
JaxOnThat
JaxOnThat10mo ago
alright, i think i know how to make this work (hopefully) I'll come back here if I can't figure it out thanks for the help, everyone
Denis
Denis10mo ago
Why on earth would they teach such useless trash 😭
Accord
Accord10mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.