Commit aa4b11c
committed
Implement
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.go as a runner for .NET file-based apps with fast incremental rebuilds1 parent 9c6c75e commit aa4b11c
26 files changed
Lines changed: 587 additions & 19 deletions
File tree
- samples
- file-based-apps
- includes
- extensions
- models
- libs
- minimal
- src
- Tests
- go
- Properties
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
Lines changed: 6 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments