Conversation
…ntal rebuilds
This change turns the `go` global tool into a first-class launcher for .NET file-based
applications (the new .cs-only project style using # directives in .NET 10+).
Behavior:
- Usage: go <file.cs> [extra args]
- The first argument is the path to the .cs entry point.
- Any arguments before a '--' separator are passed through to 'dotnet publish'.
- Arguments after '--' (or all arguments if no separator) are forwarded to the
published application at runtime.
- Fast path / caching:
- A <file>.stamp file is maintained next to the source .cs file.
- On first run (or when inputs change), the tool invokes 'dotnet publish <file.cs>'
while injecting custom MSBuild logic from go.targets.
- go.targets hooks CoreCompile to record every real input source file (as 'input = ...')
and hooks Publish to record the final published app executable path (as 'app = ...')
into the stamp file (controlled via the GoConfig environment variable).
- Before publishing, BuildState.TryRead + BuildManager.IsUpToDate checks whether
the recorded app binary exists and has a newer last-write time than all the
recorded input files. If so, publish is completely skipped.
- The app is then launched directly via ProcessRunner.
- Implementation details:
- Uses ConsoleAppFramework for argument parsing and help.
- DotnetMuxer (previous change) locates the real dotnet executable.
- ProcessRunner handles both the publish invocation (with env) and final app exec.
- GoArgs.Split cleanly separates publish vs. app arguments at '--'.
- Stamp parsing is robust (handles UTF8 BOM, forward vs backslashes, comments).
- BuildManager performs mtime-based freshness checks.
- Tests:
- GoArgsTests: separator cases (no sep, leading, trailing, normal).
- GoBuildCacheTests: up-to-date / stale / missing app scenarios.
- GoConfigReaderTests (BuildStateTests): parsing of multi-input stamps, BOM, paths.
- Samples:
- samples/minimal: trivial hello.cs
- samples/file-based-apps: rich showcase using #:property, #:package (Spectre),
#:include, #:ref, Directory.Build.*, config files, etc. Includes launch profile
friendly files.
- Other:
- go.csproj updated to include and publish go.targets.
- help.md regenerated from the new CLI.
- launchSettings.json updated for convenient debugging against the showcase sample.
This delivers a snappy 'go file.cs' experience for modern file-based .NET programs
while correctly handling incremental compilation and argument passthrough.
Member
Author
🧪 Details on Ubuntu 24.04.4 LTSfrom retest v1.1.0 on .NET 10.0.9 with 💜 by @devlooped |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This change turns the
goglobal tool into a first-class launcher for .NET file-based applications (the new .cs-only project style using # directives in .NET 10+).Behavior
Usage:
go <file.cs> [extra args]--separator are passed through todotnet publish.--(or all if no separator) are forwarded to the published application.Fast path / caching:
<file>.stampfile is maintained next to the source.dotnet publish <file.cs>while injectinggo.targetsviaCustomAfterMicrosoftCSharpTargets+GoConfigenv.go.targetsrecords inputs duringCoreCompileand the final published app path afterPublish.BuildManager.IsUpToDate+BuildState.TryReadskips publish entirely when the cached app is newer than all inputs (mtime checks).ProcessRunner.Components:
Program.cs: new ConsoleAppFramework entrypoint with caching logic.GoArgs.cs: splits args at--.BuildManager.cs+BuildState: stamp parsing and freshness check.ProcessRunner.cs: publish + run execution.go.targets: MSBuild hooks for input/app recording.Tests added for arg splitting and cache logic.
Samples demonstrating real file-based app usage (minimal + rich showcase with #:property / #:package / #:include / #:ref).
Packaging, help, and dev settings updated.
Delivers a fast, script-like
go file.csexperience on top of full .NET 10+ file-based programs.