From 9a609bf08ac1b6157dbdfb827fc01e771d71262e Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Fri, 5 Jun 2026 11:43:40 +0200 Subject: [PATCH] feat: make C# dotnet target framework configurable via DOTNET_TARGET_FRAMEWORK (#9454) * feat: make C# dotnet target framework configurable via DOTNET_TARGET_FRAMEWORK Co-Authored-By: Claude Opus 4.8 (1M context) * fix: include dotnet target framework in C# binary cache key Co-Authored-By: Claude Opus 4.8 (1M context) --------- Co-authored-by: Claude Opus 4.8 (1M context) --- backend/windmill-worker/src/csharp_executor.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/windmill-worker/src/csharp_executor.rs b/backend/windmill-worker/src/csharp_executor.rs index 70df9fb4e0..944236cf2b 100644 --- a/backend/windmill-worker/src/csharp_executor.rs +++ b/backend/windmill-worker/src/csharp_executor.rs @@ -56,9 +56,13 @@ const DOTNET_ROOT_DEFAULT: &str = "C:\\Program Files\\dotnet"; #[cfg(unix)] const DOTNET_ROOT_DEFAULT: &str = "/usr/share/dotnet"; +#[cfg(feature = "csharp")] +const DOTNET_TARGET_FRAMEWORK_DEFAULT: &str = "net9.0"; + #[cfg(feature = "csharp")] lazy_static::lazy_static! { static ref DOTNET_ROOT: String = std::env::var("DOTNET_ROOT").unwrap_or_else(|_| DOTNET_ROOT_DEFAULT.to_string()); + static ref DOTNET_TARGET_FRAMEWORK: String = std::env::var("DOTNET_TARGET_FRAMEWORK").unwrap_or_else(|_| DOTNET_TARGET_FRAMEWORK_DEFAULT.to_string()); } #[cfg(feature = "csharp")] @@ -212,6 +216,7 @@ fn gen_cs_proj( ) }; + let target_framework = DOTNET_TARGET_FRAMEWORK.as_str(); write_file( job_dir, "Main.csproj", @@ -219,7 +224,7 @@ fn gen_cs_proj( r#" Exe - net9.0 + {target_framework} enable WindmillScriptCSharpInternal.Wrapper true @@ -510,9 +515,10 @@ pub async fn handle_csharp_job( let ws_suffix = crate::workspace_registry_cache_suffix(&job.workspace_id).await; let mut hash = calculate_hash(&format!( - "{}{}", + "{}{}{}", inner_content, - requirements_o.unwrap_or(&String::new()) + requirements_o.unwrap_or(&String::new()), + DOTNET_TARGET_FRAMEWORK.as_str() )); hash.push_str(&ws_suffix); let bin_path = format!("{}/{hash}", *CSHARP_CACHE_DIR);