Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.3.0] - 2026-11-22

This minor release adds Windows-only support for legacy .NET Framework target frameworks (`net471`, `net472`, `net48`, `net481`) across both `console` and `test` modes, while preserving manifest `schemaVersion` 1 and existing modern .NET execution behavior.

### Added

- Added Windows-only support for legacy .NET Framework TFMs (`net471`, `net472`, `net48`, `net481`) in `csrun.ps1`, bypassing the .NET Core release index, SDK channel check, and `--list-runtimes` check while still building with a selected .NET 10+ SDK and failing fast on non-Windows platforms and inside Linux containers,
- Added an isolated temporary SDK-style `.csproj` fallback in `console` mode for `.NET Framework` targets (since `dotnet run --file` does not support `.NET Framework` TFMs directly), stripping validated matching preamble directives via `Get-ConsoleSource -StripDirectives`, configuring `LangVersion=latest` and `Microsoft.NETFramework.ReferenceAssemblies@1.0.3` (`PrivateAssets="All"` unless already pinned in `dependsOn`) for both `console` and `test` `.NET Framework` projects, and cleaning up the temporary directory in `finally`,
- Added unit, integration, and container test coverage in `tests/csrun.Tests.ps1` and `tests/container.Tests.ps1` for `net471`–`net481` validation, rejection of unsupported TFMs (`netstandard2.0`, `net45`, `net46`, `net461`, `net462`, `net47`, `net482`, `net48-windows`), non-Windows and Linux-container rejection, `net48` console and xUnit v3 execution against `lib/netstandard2.0` package assets with exit-status and stderr preservation, and preamble directive matching/conflict handling,
- Added documentation in `README.md` covering Windows-only `net471`–`net481` support, release-index/runtime-list bypass, non-executable TFM rejection, temporary `.csproj` fallback, and `test` mode `.NET Framework` project configuration.

### Changed

- Generalized `Write-TestProject` to `Write-Project` in `csrun.ps1`, adding `WarningsAsErrors=NU1603;NU1605` to generated `.csproj` files and passing `--framework` to `dotnet run --project` in `test` mode.

## [0.2.2] - 2026-11-18

This patch release extends Docker publishing with release-versioned SDK aliases alongside the existing movable convenience tags. The standalone native PowerShell engine (`csrun.ps1`), manifest schema version 1 and container execution contract remain unchanged.
Expand Down Expand Up @@ -58,6 +73,7 @@ This is the first release that introduces csrun as a standalone PowerShell scrip
- Added pull request and tag release workflows that run the test suite on Windows with the .NET 11 SDK and a .NET 10 compatibility job, then create a draft GitHub release with the tested `csrun.ps1` attached,
- Added the MIT license.

[0.3.0]: https://github.com/codebeltnet/csrun/compare/v0.2.2...v0.3.0
[0.2.2]: https://github.com/codebeltnet/csrun/compare/v0.2.1...v0.2.2
[0.2.1]: https://github.com/codebeltnet/csrun/compare/v0.2.0...v0.2.1
[0.2.0]: https://github.com/codebeltnet/csrun/compare/v0.1.0...v0.2.0
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,21 @@ Direct options default to `console`, the latest supported GA LTS framework, and
| --- | --- |
| `schemaVersion` | Required integer `1`. |
| `mode` | Required `console` or `test`, case-insensitive. |
| `framework` | Optional .NET 10+ TFM such as `net11.0` or `net11.0-windows`. Omission selects the highest supported GA LTS channel; an explicit value is preserved and must identify a supported GA LTS or STS channel or the latest preview/go-live channel. RIDs such as `win-x64` are invalid. Platform availability is checked by the SDK. |
| `framework` | Optional .NET 10+ TFM such as `net11.0` or `net11.0-windows`, or a legacy .NET Framework TFM (`net471`, `net472`, `net48`, `net481`) natively on Windows only. Omission selects the highest supported GA LTS channel; an explicit modern .NET value is preserved and must identify a supported GA LTS or STS channel or the latest preview/go-live channel. Legacy .NET Framework targets fail fast on Linux/macOS and inside Linux containers. RIDs such as `win-x64` and non-executable TFMs such as `netstandard2.0` are invalid. Platform availability is checked by the SDK. |
| `source` | Required nonempty string containing a complete program or test source. Multiline text, quotes, Unicode, and line endings are preserved. |
| `dependsOn` | Optional array of `PackageId@ExactVersion` pins, including prereleases. Identical duplicates collapse; conflicting versions, ranges, wildcards, and unversioned packages fail. Use three or four numeric version components. |
| `sdk` | Optional `Microsoft.NET.Sdk` (default) or `Microsoft.NET.Sdk.Web`. Never inferred. |
| `frameworkReferences` | Optional array of framework reference names. Test projects emit explicit, XML-escaped references. For console applications, only `Microsoft.AspNetCore.App` with explicitly selected `Microsoft.NET.Sdk.Web` is supported, through the SDK's implicit reference. Other console references fail with a diagnostic. |

Unknown fields are rejected to expose misspellings. No package discovery, source wrapping, method mode, or source rewriting occurs. Ordinary transitive NuGet dependencies still resolve normally. Source-only methods without a runnable entry point produce the actual compiler error.

Both modes validate the target against Microsoft's [release index](https://raw.githubusercontent.com/dotnet/core/main/release-notes/releases-index.json), cached for up to 12 hours. If the index and a recent valid cache are unavailable, execution fails. An explicit preview target is the opt-in; no automatic fallback occurs when the default LTS cannot run. The selected SDK follows `global.json`, must be .NET 10 or newer, and must support the target. A newer SDK can build an older supported target. The corresponding .NET runtime and any required ASP.NET shared framework must be installed; csrun installs neither. Platform-specific build requirements are checked by the SDK.
Both modes validate modern .NET targets against Microsoft's [release index](https://raw.githubusercontent.com/dotnet/core/main/release-notes/releases-index.json), cached for up to 12 hours. If the index and a recent valid cache are unavailable, execution fails. An explicit preview target is the opt-in; no automatic fallback occurs when the default LTS cannot run. Legacy .NET Framework targets (`net471`–`net481`) bypass the .NET Core release index and runtime list, require Windows natively, and still build using the selected .NET 10+ SDK. The selected SDK follows `global.json`, must be .NET 10 or newer, and must support the target. A newer SDK can build an older supported target. For modern .NET targets, the corresponding .NET runtime and any required ASP.NET shared framework must be installed; csrun installs neither. Platform-specific build requirements are checked by the SDK.

Console mode prepends SDK, target framework, and pinned package directives to the source stream and invokes `dotnet run -`. If a current-directory project exists, SDK 11 would select it first; csrun instead uses an isolated temporary `.cs` file and `dotnet run --file` to force file-based execution while retaining the program's working directory. It creates no console project. The SDK manages its own normal build cache. Approximate NuGet matches and downgrades are errors, preventing an unavailable pin from silently becoming another version.
Console mode prepends SDK, target framework, and pinned package directives to the source stream and invokes `dotnet run -` for modern .NET targets. If a current-directory project exists, SDK 11 would select it first; csrun instead uses an isolated temporary `.cs` file and `dotnet run --file` to force file-based execution while retaining the program's working directory. It creates no console project for modern .NET targets. Because `dotnet run --file` does not support `.NET Framework` TFMs directly, `.NET Framework` console manifests fall back to an isolated temporary SDK-style `.csproj` (with `LangVersion=latest` and `Microsoft.NETFramework.ReferenceAssemblies`, removed in `finally`) and run via `dotnet run --project ... --framework <tfm>`. The SDK manages its own normal build cache. Approximate NuGet matches and downgrades are errors, preventing an unavailable pin from silently becoming another version.

Existing source directives must be in the leading preamble (blank lines, leading comments, and C# preprocessor directives such as `#nullable` are permitted). Only matching SDK, target framework, and manifest package directives are supported. Matching directives remain in the original source and are not emitted again. Multiple occurrences of the same source setting fail explicitly because the SDK rejects duplicate directives. Conflicts and other preamble directives also fail explicitly. Build customization outside this contract belongs in a future schema, not arbitrary MSBuild directives.
Existing source directives must be in the leading preamble (blank lines, leading comments, and C# preprocessor directives such as `#nullable` are permitted). Only matching SDK, target framework, and manifest package directives are supported. Matching directives remain in the original source and are not emitted again (and are stripped when falling back to a temporary `.csproj` for `.NET Framework` targets). Multiple occurrences of the same source setting fail explicitly because the SDK rejects duplicate directives. Conflicts and other preamble directives also fail explicitly. Build customization outside this contract belongs in a future schema, not arbitrary MSBuild directives.

Test mode writes the original source to a minimal executable project in a unique temporary directory and runs `dotnet run --project ... -- --show-live-output on --progress off --no-banner`. It uses **xunit.v3@4.0.3** by default, with `UseMicrosoftTestingPlatformRunner=true`. Explicit stable xunit.v3 **4.0 patch versions >= 4.0.3** are accepted as the supported MTP v2 compatibility band; other engine variants and incompatible versions are rejected. User packages are added as exact NuGet references. The project is removed in `finally` after successful runs, compilation/restore errors, or failed tests. Forced process termination cannot guarantee cleanup.
Test mode writes the original source to a minimal executable project in a unique temporary directory and runs `dotnet run --project ... --framework <tfm> -- --show-live-output on --progress off --no-banner`. It uses **xunit.v3@4.0.3** by default, with `UseMicrosoftTestingPlatformRunner=true`. For `.NET Framework` targets, the project also sets `LangVersion=latest` and references `Microsoft.NETFramework.ReferenceAssemblies` (unless explicitly pinned in `dependsOn`). Explicit stable xunit.v3 **4.0 patch versions >= 4.0.3** are accepted as the supported MTP v2 compatibility band; other engine variants and incompatible versions are rejected. User packages are added as exact NuGet references. The project is removed in `finally` after successful runs, compilation/restore errors, or failed tests. Forced process termination cannot guarantee cleanup.

The Codebelt example discovers one passing test and displays `started`, `2`, and `finished` through live `ITestOutputHelper` output. Its `HasTestOutput` assertion only checks that an output helper exists; the integration suite separately verifies the three visible lines. Facts, theories, async tests, constructor injection, fixture disposal, and skipped tests run through the actual xUnit engine. Failed assertions return MTP exit **2**; an empty assembly returns **8**. csrun preserves child stdout/stderr and exit status; validation and prerequisite failures return **1**. `$LASTEXITCODE` is available after local invocation; `pwsh -File ./csrun.ps1 ...` propagates it to the shell. Scriptblock invocation leaves the calling session alive and sets `$LASTEXITCODE`.

Expand Down
Loading