According to the documentation, Cake can run on .Net core. However, when running the build.sh package for linux, it requires mono.
How can I run a cake script without relying on mono on Linux?
@trondhindenes You will need to install the Cake.CoreClr package instead of the Cake. We currently do not have any bootstrappers for Cake.CoreClr that doesn't use NuGet to fetch packages so you will need to download the packages by some other means.
I think @devlead have written scripts for this.
Here's an example bootstrapper for running only on .NET Core
https://github.com/devlead/BitbucketPipelinesShield/blob/master/build.sh
Thanks!
I'm getting this: The specified framework 'Microsoft.NETCore.App', version '1.0.4' was not found, I guess it's caused by outdated references in the Cake.CoreCLR. Nuget.org doesnt list any dependencies for the package, so it's hard to see if the newest versions are updated either. It would be great if you could publish more metadata to nuget.
Which version of the .NET CLI do you have installed? Package has no dependencies as everything but the .NET CLI is in the package.
The script which the bootstrap installer downloads is not compatible with my OS (Ubuntu 17) it seems, so I commented it out - hoping that I could use one of the installed .net core versions already on my computer instead - which didn't work. But no worries, I can install some older CoreFX runtimes/SDKs tomorrow and try again then. Will report back. I guess the script could be a made to check if a framework download is needed before it goes ahead and downloads it, but no biggie. I'll report back once I've looked more at this in the morning.
The example supplied script downloads 0.19.3, latest version of Cake is 0.21.1 so you could try getting latest version if you haven't already.
Which version of the .NET CLI & SDK do you have installed? Cake currently compiled with .NET CLI 1.1.0 and SDK 1.0.4.
The specified framework 'Microsoft.NETCore.App', version '1.0.4' was not found.
- Check application dependencies and target a framework version installed at:
/usr/share/dotnet/shared/Microsoft.NETCore.App
- The following versions are installed:
1.1.2
1.1.1
and
~/Documents/projects/cakecorefx î‚° dotnet --version
1.0.4
I guess I'm mising the 1.1.0 .Net cli. Version numbers in .Net confuse me.
All I get so far after hours of struggling is "Failed to initialize CoreCLR, HRESULT: 0x80131500"
I'm on a Docker image with Debian Stretch (microsoft/aspnetcore-build:1.0-2.0`)
dotnet --version is working (version 2.0.0)
mono --version also (Mono JIT compiler version 4.6.2 (Debian 4.6.2.7+dfsg-1)
I'm using a modified build.sh script from @devlead (removed core cli install since it's in the docker image already).
I turns out it is because the Cake dll depends on libicu52. Manually installing it by running
wget http://ftp.de.debian.org/debian/pool/main/i/icu/libicu52_52.1-8+deb8u5_amd64.deb && dpkg -i libicu52_52.1-8+deb8u5_amd64.deb
solved it for me.
Would it be possible to get rid of this dependency?
I'm looking into this, to see what it takes to run Cake on .NET Core 2.0
An easier solution to this might be to create a "self-contained" deployment for Cake.CoreClr (https://docs.microsoft.com/en-us/dotnet/core/deploying/#self-contained-deployments-scd)
I've spent all morning trying to get Cake.CoreClr running in an environment where only the 2.0 SDK is installed (installing 1.0.4 locally for example) but just gave up. A self contained install might solve this.
@elevate-andrewlock To do an OS specific publish and you get a cake binary that's framework independent you'll do something like
dotnet restore .\Cake\Cake.csproj -r ubuntu.16.04-x64
dotnet build .\Cake\Cake.csproj -r ubuntu.16.04-x64 -f netcoreapp1.0
dotnet publish .\Cake\Cake.csproj -r ubuntu.16.04-x64 -f netcoreapp1.0
which will give you an src/Cake/bin/Debug/netcoreapp1.0/ubuntu.16.04-x64/publish folder and there you'll find an native Cake binary with no need for "dotnet" core and should work and can be tested with
./Cake --version
One of the issues with this is that the result will be OS specific and potentially we would need to publish/package a version for each os, which might be where we end up int the feature, looking at the RID docs there would be a few to support (this is subject to change though)
win7-x64win7-x86win8-x64win8-x86win8-armwin81-x64win81-x86win81-armwin10-x64win10-x86win10-armwin10-arm64rhel.7-x64ubuntu.14.04-x64ubuntu.14.10-x64ubuntu.15.04-x64ubuntu.15.10-x64ubuntu.16.04-x64ubuntu.16.10-x64centos.7-x64debian.8-x64fedora.23-x64fedora.24-x64opensuse.13.2-x64opensuse.42.1-x64ol.7-x64ol.7.0-x64ol.7.1-x64ol.7.2-x64linuxmint.17-x64linuxmint.17.1-x64linuxmint.17.2-x64linuxmint.17.3-x64linuxmint.18-x64osx.10.10-x64osx.10.11-x64osx.10.12-x64@devlead I believe it's also possible to publish all RID's into a single folder, so you end up with a sub-folder for each RID, containing platform specific files. You can also publish the earliest RID for a platform e.g. win7-x64 and omit later versions e.g. win10-x64 as the earlier version has all the files needed for all versions (Tested this with Windows but not Mac or Linux). In theory you end up one sub-folder for mac and Windows and then one for each linux distro. Not sure what the final file size would be.
I don't think we necessarily have to do that. The main problem now is that there is no .NET Core App 2.0 compatible version of Cake released. This should be a separate package besides the existing CoreClr one I think, or else we have to create some hierarchy in the Cake.CoreClr package.
While working on this, I had to update xUnit to the latest version (or else xUnit won't run on a machine with only .NET Core 2.0 installed), but I found a bug with xUnit: https://github.com/xunit/xunit/issues/1443
it's a shame one can't dotnet publish from a nuget package because Cake.dll could essentially be an .NET Standard 1.6 assembly and a netcore2.0 app "should" be able to reference that.
Yeah, it is all a bit dicey at the moment.
As of now Cake Tool can be installed as global tool (see https://www.nuget.org/packages/Cake.Tool/) and the tool can be run via dotnet-cake. The tool will execute your cake script.
Yep, I've already used it and it is working like a charm!
Does the cake tool use .NET Framework or .NET Core to execute .cake scripts?
ATM checking nuget packages we provide
I think this can be closed. Available runners and supported plattforms are documented at https://cakebuild.net/docs/running-builds/runners/#supported-platforms.
Most helpful comment
ATM checking nuget packages we provide