C
C#9mo ago
Wagi

✅ Build on Windows for Windows and Linux simultaneously

Hello, I'm using Visual Studio 2022 on Windows 10 and making a Console Application. I would like to configure the project to build simultaneously for both Windows 10 x64 and Debian 12 x64. How could I achieve that ? My knowledge of C# and its specificities is limited Thank you for your time
19 Replies
SpReeD
SpReeD9mo ago
TargetFramework .NET 8.0 and publish profiles for both OS
Wagi
WagiOP9mo ago
I see thank you. Do I have to make a new Profile (.pubxml) for each configuration and platform ? It seems I cannot set multiple values for the Target's location, framework, runtime and configuration Or can I edit the Profile (.pubxml) file to achieve that ?
SpReeD
SpReeD9mo ago
Publish a .NET console application using Visual Studio - .NET
Learn how to use Visual Studio to create the set of files that are needed to run a .NET application.
Application publishing - .NET
Learn about the ways to publish a .NET application. .NET can publish platform-specific or cross-platform apps. You can publish an app as self-contained or as framework-dependent. Each mode affects how a user runs your app.
Wagi
WagiOP9mo ago
Alright, thank you for your time
Pobiega
Pobiega9mo ago
You don't need profiles at all. Just use dotnet publish instead and put your settings in the csproj Such as RuntimeIdentifiers
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
Wagi
WagiOP9mo ago
Hey, That sounds more like what I was looking for indeed. That said, I'm quite a newbie with C#. What are CI, CD, and CLI ? CLI (command line interpreter ?) I had seen the RID possibilities but I think I didn't get it to work in the .csproj file. That said the a command line doing it all is perfect. Where do I place the commands to keep using the interface and not the console ? How do I chain commands with dotnet ?
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX9mo 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. Single file publishing | Runtime Identifier (RID) catalog | dotnet publish
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
Wagi
WagiOP9mo ago
Would this be correct commands ?
dotnet publish --configuration Debug --output <mypath> --self-contained true --runtime win-x64 -p:PublishSingleFile=true
dotnet publish --configuration Debug --output <mypath> --self-contained true --runtime linux-x64 -p:PublishSingleFile=true
dotnet publish --configuration Release --output <mypath> --self-contained true --runtime win-x64 -p:PublishSingleFile=true
dotnet publish --configuration Release --output <mypath> --self-contained true --runtime linux-x64 -p:PublishSingleFile=true
dotnet publish --configuration Debug --output <mypath> --self-contained true --runtime win-x64 -p:PublishSingleFile=true
dotnet publish --configuration Debug --output <mypath> --self-contained true --runtime linux-x64 -p:PublishSingleFile=true
dotnet publish --configuration Release --output <mypath> --self-contained true --runtime win-x64 -p:PublishSingleFile=true
dotnet publish --configuration Release --output <mypath> --self-contained true --runtime linux-x64 -p:PublishSingleFile=true
Where would I place them within Visual Studio ?
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
Wagi
WagiOP9mo ago
Well, I want to debug on Windows using the debugger and release on Linux. So I don't need the pdb for Linux but doesn't Visual Studio need them to debug ?
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
Wagi
WagiOP9mo ago
Alright, that's where I got confused.
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
Wagi
WagiOP9mo ago
I see, thank you for your time and knowledge
Unknown User
Unknown User9mo ago
Message Not Public
Sign In & Join Server To View
MODiX
MODiX9mo ago
Use the /close command to mark a forum thread as answered
Want results from more Discord servers?
Add your server