From 8d426011e31ca7d1528f09f885e825177523bd72 Mon Sep 17 00:00:00 2001 From: Marco Silva Date: Mon, 13 Jul 2026 10:13:42 +0000 Subject: [PATCH] fix(scaffold): use dynamic TargetFramework for data package Actions project The Data command always passed net6.0 as the target framework when scaffolding the Actions project, regardless of MES version. This caused the Actions project to target net6.0 even for MES 11+ where net8.0 is expected. Align with BusinessCommand and TestCommand by resolving the target framework dynamically via IDependencyVersionService.DotNetTargetFramework(), which returns net8.0 for MES >= 11 and net6.0 otherwise. Fixes #770 --- cmf-cli/Commands/new/DataCommand.cs | 2 +- tests/Specs/New.cs | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/cmf-cli/Commands/new/DataCommand.cs b/cmf-cli/Commands/new/DataCommand.cs index 9de6fda78..4118184a3 100644 --- a/cmf-cli/Commands/new/DataCommand.cs +++ b/cmf-cli/Commands/new/DataCommand.cs @@ -72,7 +72,7 @@ protected override List GenerateArgs(IDirectoryInfo projectRoot, IDirect "--rootRelativePath", relativePathToRoot, "--repositoryType", repoType.ToString() }); - args.AddRange(new []{ "--targetFramework", DependencyVersionService.NET6TARGETFRAMEWORK }); + args.AddRange(new []{ "--targetFramework", ExecutionContext.ServiceProvider.GetService().DotNetTargetFramework(version) }); return args; } diff --git a/tests/Specs/New.cs b/tests/Specs/New.cs index f37c66095..729826b5a 100644 --- a/tests/Specs/New.cs +++ b/tests/Specs/New.cs @@ -208,6 +208,35 @@ public void Data() RunNew(new DataCommand(), "Cmf.Custom.Data"); } + [Fact, Trait("TestCategory", "Integration")] + public void Data_TargetFramework_Net8_For_MES11() + { + RunNew(new DataCommand(), "Cmf.Custom.Data", + extraAsserts: args => + { + var (_, dir) = args; + var actionsCsproj = Path.Combine(dir, "Cmf.Custom.Data", "DEEs", "Cmf.Custom.tenant.Actions.csproj"); + File.Exists(actionsCsproj).Should().BeTrue(); + var content = File.ReadAllText(actionsCsproj); + content.Should().Contain("net8.0"); + }); + } + + [Fact, Trait("TestCategory", "Integration")] + public void Data_TargetFramework_Net6_For_MES10() + { + RunNew(new DataCommand(), "Cmf.Custom.Data", + mesVersion: "10.2.0", + extraAsserts: args => + { + var (_, dir) = args; + var actionsCsproj = Path.Combine(dir, "Cmf.Custom.Data", "DEEs", "Cmf.Custom.tenant.Actions.csproj"); + File.Exists(actionsCsproj).Should().BeTrue(); + var content = File.ReadAllText(actionsCsproj); + content.Should().Contain("net6.0"); + }); + } + [Fact, Trait("TestCategory", "LongRunning"), Trait("TestCategory", "Integration")] public void Data_WithBusiness() {