Can Cake be used to build a .NET Core 3.1 console application for Windows, Linux and Mac... on a Windows machine? #3564
-
Hey fellow C# developers, I'm looking into Cake to improve my automated building skills and my life in general. Can Cake be used to build a .NET Core 3.1 console application for Windows, Linux and Mac... on a Windows machine? If yes, do you have an example of how the cakefile should look? I did some preliminary research, but I can't understand if it's doable or not. My idea is to click a button in Visual Studio or run a command, and Cake will create three binaries in a folder, one binary for platform. Thank you for your kind help. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Cake is a build orchestration tool... It doesn't actually compile the code, and instead it helps you run the tools that compile the code and produce binaries in a scripting way, using C#. It makes it easier to run tools like So the question to you is: Are you currently able to build a .NET Core 3.1 Console Applications for Windows, Linux and Mac... on a Windows machine without Cake? 😉 If your answer is yes, then it means it can also be done with Cake, otherwise no You want to look at the .NET application publishing overview to see what your options are (framework-dependent, self-contained, etc.), and also look at the dotnet publish YourProject.csproj --configuration Release --framework netcoreapp3.1 --runtime win-x64
dotnet publish YourProject.csproj --configuration Release --framework netcoreapp3.1 --runtime linux-x64
dotnet publish YourProject.csproj --configuration Release --framework netcoreapp3.1 --runtime osx.10.11-x64 Once you figure that out, if you want to use Cake, then it's just a conversion to the Cake C# DSL using the different aliases provides, such as the DotNetCorePublish("YourProject.csproj", new DotNetCorePublishSettings
{
Configuration = "Release",
Framework = "netcoreapp3.1",
Runtime = "linux-x64",
});
// etc... I suggest you take a look at the documentation on Script Aliases and the Getting Started section. That said, if you are able to leverage GitHub Actions, it's fairly easy to run the exact same Cake build script in multiple operating systems. You can see an example of that in my project NaturalStringExtensions where the exact same |
Beta Was this translation helpful? Give feedback.
-
@augustoproiete Very grateful for your time and help! Have a nice night/day! |
Beta Was this translation helpful? Give feedback.
Cake is a build orchestration tool... It doesn't actually compile the code, and instead it helps you run the tools that compile the code and produce binaries in a scripting way, using C#.
It makes it easier to run tools like
dotnet build
,dotnet publish
,msbuild
, etc. using C#, instead of having to use PowerShell, Bash, or other scripting languages to orchestrate your build process.So the question to you is: Are you currently able to build a .NET Core 3.1 Console Applications for Windows, Linux and Mac... on a Windows machine without Cake? 😉 If your answer is yes, then it means it can also be done with Cake, otherwise no☺️
You want to look at the .NET application publishing overview to …