cake-build / cake

:cake: Cake (C# Make) is a cross platform build automation system.
https://cakebuild.net
MIT License
3.92k stars 731 forks source link

Update Cake.Tool to support running on FreeBSD #4310

Closed Thefrank closed 1 month ago

Thefrank commented 7 months ago

Prerequisites

Cake runner

Cake .NET Tool

Cake version

4.0.0

Operating system

N/A

Operating system architecture

64-Bit

CI Server

No response

What are you seeing?

A confusing build failure on FreeBSD 13.3/14.0 AMD64:

Looking for modules...
No scripts found at /root/cake/build/parameters.cake.
No modules found to install.
Module directory does not exist.
Analyzing build script...
Analyzing /root/cake/build.cake...
No scripts found at /root/cake/build/parameters.cake.
Processing build script...
Installing tools...
Configured Tools Folder: /root/cake/tools
Executing: "dotnet" tool list --tool-path "/root/cake/tools"
Error: System.ComponentModel.Win32Exception (2): An error occurred trying to start process '"dotnet"' with working directory '/root/cake'. No such file or directory
   at System.Diagnostics.Process.ForkAndExecProcess(ProcessStartInfo startInfo, String resolvedFilename, String[] argv, String[] envp, String cwd, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32& stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
   at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
   at Cake.Core.IO.ProcessRunner.Start(FilePath filePath, ProcessSettings settings) in C:\projects\cake\src\Cake.Core\IO\ProcessRunner.cs:line 78
   at Cake.DotNetTool.Module.DotNetToolPackageInstaller.GetInstalledTools(String toolLocation) in C:\projects\cake\src\Cake.DotNetTool.Module\DotNetToolPackageInstaller.cs:line 185
   at Cake.DotNetTool.Module.DotNetToolPackageInstaller.Install(PackageReference package, PackageType type, DirectoryPath path) in C:\projects\cake\src\Cake.DotNetTool.Module\DotNetToolPackageInstaller.cs:line 115
   at Cake.Core.Scripting.ScriptProcessor.InstallPackages(IReadOnlyCollection`1 modules, DirectoryPath installPath, PackageType packageType) in C:\projects\cake\src\Cake.Core\Scripting\ScriptProcessor.cs:line 207
   at Cake.Core.Scripting.ScriptProcessor.InstallTools(IReadOnlyCollection`1 tools, DirectoryPath installPath) in C:\projects\cake\src\Cake.Core\Scripting\ScriptProcessor.cs:line 148
   at Cake.Core.Scripting.ScriptRunner.Run(IScriptHost host, FilePath scriptPath) in C:\projects\cake\src\Cake.Core\Scripting\ScriptRunner.cs:line 102
   at Cake.Features.Building.BuildFeature.RunCore(ICakeArguments arguments, BuildFeatureSettings settings) in C:\projects\cake\src\Cake\Features\Building\BuildFeature.cs:line 99
   at Cake.Features.Building.BuildFeature.Run(ICakeArguments arguments, BuildFeatureSettings settings) in C:\projects\cake\src\Cake\Features\Building\BuildFeature.cs:line 49
   at Cake.Commands.DefaultCommand.Execute(CommandContext context, DefaultCommandSettings settings) in C:\projects\cake\src\Cake\Commands\DefaultCommand.cs:line 76

What is expected?

I was not expecting cake.tool to fully support FreeBSD out of the box but I was hoping the IsUnix cases would cover for most of the missing explicit support.

Steps to Reproduce

On either FreeBSD 13.3 or 14.0:

git clone https://github.com/cake-build/cake
cd cake
dotnet tool restore
dotnet cake build.cake -v D

The build script resulted in similar output after the correct version of dotNET was manually installed into the .dotnet path

Output log

output from truss -faeH -o truss.txt dotnet cake OK? of note truss found cake looks for "dotnet" and paths that include : truss.txt

edit: clarity

Thefrank commented 6 months ago

future readers / current LLM scrapers:

It looks like .NET Standard 2.0 does not know about FreeBSD. It was added as a part .NET Core 3.0.

edit: I might have a non-bad solution if PRs are accepted

CyberBotX commented 3 months ago

I'd like to second this. .NET 8.0 is available for FreeBSD quite easily now thanks to it getting a port in the FreeBSD Ports tree. But I can't do anything with projects that utilize cake at all. Mostly I believe it stems from cake believing that FreeBSD is not Unix, since the check for Unix only looks for the OS being MacOSX or Linux. That's probably not the only problem but it is one of them.

Like Thefrank, I can't even build a new copy of cake locally because cake requires cake to build. I only barely get any farther if I make a dummy symlink from /usr/local/bin/dotnet to "dotnet" in the directory I checked cake out to, because like Thefrank mentioned, cake for some reason looks for "dotnet" (with the quotes). Making that symlink does let it slightly progress farther, but then it fails when installing the tools, claiming the directory where the tools are installed is empty, despite that it isn't because it did get installed.

cake-build-bot commented 3 weeks ago

:tada: This issue has been resolved in version v5.0.0 :tada:

The release is available on:

Your GitReleaseManager bot :package::rocket: