✅ 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
TargetFramework .NET 8.0 and publish profiles for both OS
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 ?Yes. Maybe you like to check out the Microsoft Docs here:
https://learn.microsoft.com/en-us/dotnet/core/tutorials/publishing-with-visual-studio?pivots=dotnet-6-0
https://learn.microsoft.com/en-us/dotnet/core/deploying/
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.
Alright, thank you for your time
You don't need profiles at all. Just use
dotnet publish
instead and put your settings in the csproj
Such as RuntimeIdentifiersUnknown User•9mo ago
Message Not Public
Sign In & Join Server To View
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•9mo ago
Message Not Public
Sign In & Join Server To View
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
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
Would this be correct commands ?
Where would I place them within Visual Studio ?
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
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•9mo ago
Message Not Public
Sign In & Join Server To View
Alright, that's where I got confused.
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
I see, thank you for your time and knowledge
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
Use the /close command to mark a forum thread as answered