Let dotnet-script roll forward to a newer .NET runtime - #2095
NickJosevski wants to merge 1 commit into
Conversation
Appreciate the shade 🤖 |
| /// whatever newer runtime is present, so C# script steps don't additionally require the exact | ||
| /// runtime dotnet-script was built against. | ||
| /// </summary> | ||
| static Dictionary<string, string> WithDotnetRollForward(Dictionary<string, string>? environmentVars) |
There was a problem hiding this comment.
DotNet script requires the dotnet sdk, not just the dotnet runtime, does this work for that?
| <PackageReference Include="System.ValueTuple" Version="4.5.0" /> | ||
| <PackageReference Include="Autofac" Version="4.8.0" /> | ||
| <PackageReference Include="System.ComponentModel.TypeConverter" Version="4.3.0" /> | ||
| <PackageReference Include="Autofac" Version="9.3.1" /> |
There was a problem hiding this comment.
this seems like a huge bump... Probably need some integration testing to make sure it's all on the up and up
zentron
left a comment
There was a problem hiding this comment.
We need to be careful with this upgrade and confirm any breaking changes that will impact users utilizing dotnet-script.
Unfortunately in this new world the customer C# scripts will now run under whatever framework we are running Calamari itself under.
Not marked as Request Changes since this is just more a comment for caution.
1b88535 to
e47255c
Compare
1af3547 to
1d13556
Compare
e47255c to
af660e7
Compare
5a197ad to
a9c3d46
Compare
a9c3d46 to
4c549d7
Compare
8702b70 to
b5274ac
Compare
Script wrappers form an execution chain and file-format replacers are tried in sequence, so a reordering changes deployment behaviour. Nothing currently detects that: every wrapper still constructs and every command still resolves, so the existing suite stays green. Two guards, both PlatformAgnostic: ContainerOrderingFixture asserts the orderings directly. The load-bearing one is ScriptWrapperPrioritiesAreUnique — ScriptEngine sorts with OrderByDescending, which is stable, so a shared priority silently hands the tie-break to the container's collection ordering. Priorities are distinct today; the test keeps them that way. The rest pin the wrapper chain for a Kubernetes/AWS/PowerShell step, the file-format replacer order, and discoverer key uniqueness. ContainerSnapshotFixture compares a rendering of the whole container against an approved file: registrations, lifetimes, collection order, and the concrete types injected into every command. Targeted assertions only catch what someone thought of; this catches anything observable that moves, which is what makes it useful across a dependency upgrade. Re-approve with CALAMARI_APPROVE_CONTAINER_SNAPSHOT=1. The snapshot is normalised so one approved file serves every platform: the OS-chosen filesystem and certificate-store implementations collapse to placeholders, Autofac's __RegistrationOrder tick counter is dropped, and collection fields render distinct element types rather than counts. Verified against the Autofac 4.8.0 -> 9.3.1 upgrade in #2095: the snapshot fails with exactly the version line plus five registrations gaining AutoActivate (the RegisterInstance ones), and all five ordering tests still pass.
b86bd05 to
8f5bedf
Compare
8f5bedf to
40355b0
Compare
The bundled dotnet-script is framework-dependent and targets Microsoft.NETCore.App 8.0.0. Framework-dependent apps do not cross a major version boundary by default, so on a machine that has .NET 10 but no .NET 8 it fails to launch with "You must install or update .NET to run this application". Setting DOTNET_ROLL_FORWARD=Major on the dotnet-script invocation lets it run on whatever newer runtime is present. The variable only engages when the requested major is absent, so where a .NET 8 runtime exists the resolved runtime is unchanged. An explicit value already set in the environment is respected rather than overwritten. Every configuration this alters is one where dotnet-script fails to launch today, so nothing can go from working to broken. Calamari itself is unaffected either way - it ships self-contained and carries its own runtime. This is only about the separate dotnet-script process. Fixes a live bug rather than only preparing for .NET 10: worker-tools:ubuntu.24.04 ships SDK 10 with no .NET 8 runtime, so C# script steps cannot run there today. Scope is launch only. A script using #r "nuget:" on a framework-provided package still fails under the .NET 10 SDK; that needs the bundled dotnet-script upgraded to 2.0.x and is tracked separately. Verified: 10 DotnetScriptFixture tests pass. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
40355b0 to
161112d
Compare
Sets
DOTNET_ROLL_FORWARD=Majoron the dotnet-script child process.Why
The bundled dotnet-script is framework-dependent, targets
Microsoft.NETCore.App 8.0.0. Framework-dependent apps don't cross major version boundary by default, machine with .NET 10 and no .NET 8 already gets error:Because
worker-tools:ubuntu.24.04ships SDK 10 with no .NET 8 runtime, so C# script steps cannot run there today.Change
Question
Answer
Nothing changes. They keep working, C# script steps included.
Microsoft.NETCore.App 8.0.0, finds your .NET 8, and runs on it.Majoronly engages when the requested major is absent. Where .NET 8 exists, is as-is.The configuration that breaks is the opposite one, so this PR fixes:
Risk
Nothing can go from working to broken. Every configuration this alters is one where dotnet-script fails to launch today; every configuration that works today has .NET 8, where the variable is inert.
DOTNET_ROLL_FORWARDalready in the environment is respected, not overwritten.Calamari.Common: 79 warnings, 0 errors — identical tomain.DotnetScriptFixturetests pass.Server will need to reference this build.