Skip to content

Feature/consolesink fixes#34

Closed
OlegZee wants to merge 32 commits intoFakeBuild:devfrom
OlegZee:feature/consolesink-fixes
Closed

Feature/consolesink fixes#34
OlegZee wants to merge 32 commits intoFakeBuild:devfrom
OlegZee:feature/consolesink-fixes

Conversation

@OlegZee
Copy link
Collaborator

@OlegZee OlegZee commented Mar 18, 2026

No description provided.

OlegZee and others added 30 commits November 8, 2019 13:29
…rencing nuget), fixed console garbling in VS, added support for substitutions in phony rules, closing database on Ctrl-C, support for Tasks in recipes
- Added new build and publish workflows for .NET projects.
- Updated .NET SDK version from 7.0 to 9.0 in global.json and project files.
#2)

* Enhance documentation and improve Shell command options in Xake scripts, new dependsOn function, updates sample code in features.fsx

* Update samples/features.fsx

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Update src/core/ScriptFuncs.fs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

---------

Co-authored-by: olegz <oleg.zaimkin@developertools.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Refactor version retrieval in build script to simplify logic and improve clarity

new feature: --resetdb flag that clears database before running build.
fix: all targets requested become lowercase while parsing CLI args.

Add stdout and stderr handlers to ShellOptions and update tests
* feature: NoPersist and Teardown options in ExecOptions
feature: new "engine" mode for library mode

* refactor: enhance file reading functions and improve XakeEngine demand handling

* Deep refactoring of exec types and engine classes

* few fixes based on code review

* Update src/core/WorkerPool.fs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* following up review notes + more doc comments

---------

Co-authored-by: olegz <oleg.zaimkin@developertools.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* feature: NoPersist and Teardown options in ExecOptions
feature: new "engine" mode for library mode

* refactor: enhance file reading functions and improve XakeEngine demand handling

* Deep refactoring of exec types and engine classes

* few fixes based on code review

* Update src/core/WorkerPool.fs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* following up review notes + more doc comments

* follow up more issues

* Refactor error logging and improve demand handling in the engine:
- fixed noPersist behavior
- demand waits for prior runs of same target to complete before start
- more tests to verify behavior

---------

Co-authored-by: olegz <oleg.zaimkin@developertools.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Add RuleBuilder implementing new rules definition syntax using "target" and "command" keywords
* new command rules are now imperative: always executed
* Update src/core/RuleBuilder.fs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

* Fix XML doc comment misassociation for `<==` operator and `needSequentially` (#8)

* Initial plan

* Fix XML doc comment placement: move needSequentially above the &lt;== doc block

Co-authored-by: OlegZee <513301+OlegZee@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: OlegZee <513301+OlegZee@users.noreply.github.com>

* Moving new command, target(s) syntax to Xake namespace (from Experimental)

---------

Co-authored-by: olegz <oleg.zaimkin@developertools.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: OlegZee <513301+OlegZee@users.noreply.github.com>
* implement typed variable system with support for CLI and environment variable resolution

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…#11)

Adds consistent teardown execution for CLI script runs so teardown targets run after both successful builds and build failures (including when ThrowOnError is enabled), aligning CLI behavior with the long-lived engine teardown flow.

Changes:

Introduces ScriptRunner.runTeardownAsync and uses it from both CLI execution and XakeEngine.StopAsync.
Updates CLI runScript to always run teardown after build completion/failure, and to preserve the original build error when teardown also fails.
Adds CLI-focused tests covering teardown on success, failure, teardown-failure reporting, and skipping teardown for --dryrun/--dump.
OlegZee added 2 commits March 16, 2026 23:17
… improve progress reporting.

improved: turning progress off for engine mode, cleaned output in tests
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes Xake’s core execution model and scripting surface by introducing a long-lived engine API, typed variable/schema support with --help integration, and updated build/test infrastructure targeting newer .NET tooling.

Changes:

  • Refactors script execution into a new ScriptRunner pipeline and adds a long-lived XakeEngine (start / Demand / StopAsync) for watch/LSP-style usage.
  • Introduces typed variables (Var.*) and varschema for CLI/env resolution + --help output.
  • Updates build scripts, samples, docs, CI workflows, and test target frameworks/tooling (notably net9.0 for tests and .NET 9 global.json).

Reviewed changes

Copilot reviewed 66 out of 68 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
xake.sln Removes Paket solution items from the solution structure.
src/tests/XakeScriptTests.fs Updates tests for new options semantics (e.g., ResetDb) and minor refactors.
src/tests/XakeEngineTests.fs Adds new tests for long-lived engine Demand/StopAsync behavior and concurrency.
src/tests/VarsTests.fs Adds comprehensive tests for typed variables, env/CLI precedence, and varschema behavior.
src/tests/tests.fsproj Moves tests to net9.0 and updates test packages; adds new test files.
src/tests/SystemTaskTests.fs Expands shell task tests (Unix-focused) and adjusts options (ThrowOnError, ResetDb).
src/tests/StorageTests.fs Adds test coverage for Storage.cleanupDb.
src/tests/ScriptErrorTests.fs Switches to ThrowOnError and adjusts logger filter and want usage.
src/tests/RecipeTests.fs Switches to ThrowOnError in test options.
src/tests/CommandTests.fs Adds tests for new command rule behavior across runs and engine demands.
src/tests/CommandLineTests.fs Refactors CLI assertions; adds teardown/resetdb/case-preservation tests.
src/core/XakeScriptBuilder.fs Introduces new script builder + long-lived XakeEngine implementation.
src/core/XakeScript.fs Moves/defines ExecOptions here; adds new operators and options (ResetDb/NoPersist/Teardown/VarSchema).
src/core/Xake.fsproj Adjusts target frameworks, compile order, and adds new core modules.
src/core/WorkerPool.fs Refactors worker pool; adds scheduler helper for yielded slots.
src/core/Vars.fs Adds typed variable API (Var.*), required/default helpers, and varschema reflection-based schema capture.
src/core/Types.fs Adds/updates domain type documentation and comments.
src/core/Tasks/Shell.fs Extends shell CE API (stdout/stderr hooks, output capture, result composition) and improves docs.
src/core/Tasks/Rm.fs Adds/updates inline documentation for rm task and aliases.
src/core/Tasks/misc.fs Adds read helpers and reorganizes write helpers (writeTargetText, bytes).
src/core/Tasks/Cp.fs Adds/updates inline documentation for copy task and alias.
src/core/ScriptRunner.fs New centralized runner converting ExecOptionsEngineOptions, handling Ctrl+C, teardown, resetdb, etc.
src/core/ScriptFuncs.fs Refactors recipe helpers; getVar now reads from ctx.Vars; adds helpers like dependsOn.
src/core/RuleBuilder.fs Adds command/target/targets builder-style rule definitions.
src/core/RecipeFunctions.fs Moves to module Xake.Recipe and streamlines helpers.
src/core/RecipeBuilder.fs Extends recipe CE to bind Task<'T> and improves inline docs.
src/core/Progress.fs Tweaks progress loop timing and console reporting (active tasks count).
src/core/Program.fs Makes ParseArgs public; adds --resetdb; changes help flow to ShowHelp; adds xakeEngine builder.
src/core/ProcessExec.fs Converts to module internal Xake.ProcessExec and adds docs for pexec.
src/core/Prelude.fs Adds small helper docs for operators/active patterns.
src/core/Pickler.fs Refactors pickler module layout and definitions into Xake.Pickler.
src/core/PathExt.fs Adds auto-open path operators module.
src/core/Path.fs Refactors into module Xake.Path and removes embedded PathExt operators (now in PathExt.fs).
src/core/FileTasksImpl.fs Adds doc comment for ensureDirCreated.
src/core/Fileset.fs Refactors into module Xake.Fileset with clearer types/docs; keeps existing behavior.
src/core/File.fs Adds documentation; modifies name comparison/hash logic.
src/core/ExecTypes.fs Splits engine-level types (EngineOptions/EngineState) vs exec context; adds var/schema types.
src/core/DependencyAnalysis.fs Updates to use ctx.Vars for var deps; signature cleanup.
src/core/Database.fs Adds noopDb, cleanupDb, backup helper, docstrings, and minor logging changes.
src/core/CommonLib.fs Refactors module declaration and documentation comments.
src/core/inner-examples.fsx Removes internal example script.
samples/rmdir.fsx Updates script header to #r "nuget: ..." reference style/version.
samples/gettingstarted.fsx Updates script references to NuGet-style #r and newer package versions.
samples/features.fsx Updates sample to dotnet fsi flow and demonstrates new command/target/dependsOn/sh features.
samples/catch_errors.fsx Updates script reference to NuGet-style #r.
samples/book/intro.fsx Updates script references to NuGet-style #r (currently with a syntax issue).
readme.md Updates badges, usage instructions, and links; shifts from FAKE to dotnet fsi.
LICENSE Updates copyright year range.
global.json Pins/requires .NET SDK 9 with major roll-forward.
build.sh Updates build invocation to dotnet fsi.
build.cmd Updates build invocation to dotnet fsi.
build.proj Removes legacy FAKE tool restore project.
build.fsx.lock Removes old paket lock for build script.
build.fsx Updates build script to new APIs (varschema, typed vars, command/targets, sh).
.vscode/settings.json Removes repo-level VS Code settings.
.travis.yml Updates Travis script to dotnet fsi (SDK version currently mismatched with global.json).
.gitignore Adds Ionide/VS Code/Claude local settings ignores.
.github/workflows/publish.yml Adds GitHub Actions workflow for tagged publish.
.github/workflows/build.yml Adds GitHub Actions workflow for PR/branch build and test.
docs/todo.md Removes outdated TODO document.
docs/tasks.md Rewrites tasks documentation around new APIs (sh/cp/rm, output capture).
docs/overview.md Replaces long overview with concise modern baseline and examples.
docs/implnotes.md Replaces legacy internals notes with updated high-level implementation notes.
docs/devprocess.md Updates dev workflow to .NET 9 / dotnet fsi commands and current release process.
docs/cheatsheet.md Adds new concise cheatsheet for current API and CLI usage.
CLAUDE.md Adds repository guidance for Claude Code (commands, architecture, conventions).
Comments suppressed due to low confidence (1)

src/core/File.fs:13

  • File path comparison is currently case-insensitive on Unix (ignoreCase = Env.isUnix), which is the opposite of typical filesystem semantics and also inconsistent with DomainTypes.Target (which uses ordinal compare on Unix and ignore-case on Windows). This can cause incorrect equality/hashing for File on Unix and break dependency tracking/caching. ignoreCase should likely be not Env.isUnix (and getFileHash should follow the same rule).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment on lines 17 to +20
let create (logger:ILogger) maxThreads =
// controls how many threads are running in parallel
let throttler = new SemaphoreSlim (maxThreads)
let log = logger.Log

let mapKey (artifact:Target) = artifact.FullName

throttler, MailboxProcessor.Start(fun mbox ->
let rec loop(map) = async {
let! msg = mbox.Receive()

match msg with
| Run(artifact, targets, action, chnl) ->
let mkey = artifact |> mapKey

match map |> Map.tryFind mkey with
| Some (task:Task<'a>) ->
log Never "Task found for '%s'. Status %A" artifact.ShortName task.Status
chnl.Reply <| Async.AwaitTask task
return! loop(map)

| None ->
do log Info "Task queued '%s'" artifact.ShortName
do! throttler.WaitAsync(-1) |> Async.AwaitTask |> Async.Ignore

let task = Async.StartAsTask (async {
try
let! buildResult = action
do log Info "Task done '%s'" artifact.ShortName
return buildResult
finally
throttler.Release() |> ignore
})
chnl.Reply <| Async.AwaitTask task
let newMap = targets |> List.fold (fun m t -> m |> Map.add (mapKey t) task) map
return! loop newMap
}
loop(Map.empty) )
// controls how many threads are running in parallel
let throttler = new SemaphoreSlim (maxThreads)
let log = logger.Log
Comment on lines +124 to +128
let makeCtx extraVars = {
Engine = engine
Vars = vars @ defaultArg extraVars []
Progress = Progress.emptyProgress()
NeedRebuild = fun _ -> false
Comment on lines +158 to +163
let details = exceptions |> Seq.last |> fun e -> e.ToString()
let errorText = errors |> String.concat "\r\n"

do ctx.Logger.Log Error "Error '%s'. See build.log for more details" errorText
do ctx.Logger.Log Verbose "Error details are:\n%A\n\n" details
do ctx.Logger.Log Message "\n\n\tBuild failed after running for %A\n" (System.DateTime.Now - start)
Comment on lines 54 to +62
let! ctx = getCtx()
let log = ctx.Logger.Log

do! trace Level.Debug "[shell] settings: '%A'" opts
do! trace Level.Debug "[shell] settings: '%A'" opts // dangerous to log all options, but we need it for debugging purposes. Consider redacting sensitive info in the future.

let handleErr s = log (opts.ErrOutLevel s) "%s %s" opts.LogPrefix s
let handleStd s = log (opts.StdOutLevel s) "%s %s" opts.LogPrefix s
let handleStd s =
log (opts.StdOutLevel s) "%s %s" opts.LogPrefix s
extraStd s
Comment on lines +50 to +55
/// Reset database before build
ResetDb: bool

/// Skip build database; every target always rebuilds.
NoPersist: bool

#!/bin/bash
dotnet restore build.proj
dotnet fake run build.fsx -- build No newline at end of file
dotnet fsi build.fsx -- -- No newline at end of file
Comment on lines 1 to 6
language: csharp
mono: latest
dotnet: 2.1.300
dotnet: 7.0.202
env: VER=$(if [[ "${TRAVIS_TAG:0:1}" == "v" ]]; then echo ${TRAVIS_TAG:1}.${TRAVIS_BUILD_NUMBER}; else echo 1.0.0.${TRAVIS_BUILD_NUMBER}; fi;)
install:
- dotnet restore build.proj
script:
- export FrameworkPathOverride=$(dirname $(which mono))/../lib/mono/4.5-api/
- dotnet fake run build.fsx -- build test -ll Diag
- dotnet fsi build.fsx -- -- build test -ll Diag
deploy:
Comment on lines 31 to 37
<ItemGroup>
<PackageReference Include="NUnit" Version="3.10.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.7" />
<PackageReference Include="NUnit3TestAdapter" Version="3.10.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.6.0" />
<PackageReference Include="NUnit" Version="3.13.3" />
<PackageReference Include="NUnit3TestAdapter" Version="4.2.1" />
<PackageReference Include="NUnit.Analyzers" Version="3.6.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0" />
</ItemGroup>
nuget Xake ~> 1.1 prerelease
nuget Xake.Dotnet ~> 1.1 prerelease //" // (1)
#r "nuget: Xake, 1.1.4.427-beta"
#r "nuget: Xake.Dotnet, 1.1.4.7-beta" (1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants