From c7726df3452c67a1f0ac76cab3bbcead02bf39e0 Mon Sep 17 00:00:00 2001 From: Jan Jones Date: Mon, 14 Jul 2025 12:28:57 +0200 Subject: [PATCH 1/4] Override default properties with custom file-level directives --- .../Run/VirtualProjectBuildingCommand.cs | 68 +++++++++++-------- .../Convert/DotnetProjectConvertTests.cs | 41 ++++++++++- .../CommandTests/Run/RunFileTests.cs | 1 - 3 files changed, 78 insertions(+), 32 deletions(-) diff --git a/src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs b/src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs index bf80f0b8c9b6..5fcfac82dd8c 100644 --- a/src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs +++ b/src/Cli/dotnet/Commands/Run/VirtualProjectBuildingCommand.cs @@ -61,6 +61,18 @@ internal sealed class VirtualProjectBuildingCommand : CommandBase "MSBuild.rsp", ]; + /// + /// Kept in sync with the default dotnet new console project file (enforced by DotnetProjectAddTests.SameAsTemplate). + /// + private static readonly FrozenDictionary s_defaultProperties = FrozenDictionary.Create(StringComparer.OrdinalIgnoreCase, + [ + new("OutputType", "Exe"), + new("TargetFramework", "net10.0"), + new("ImplicitUsings", "enable"), + new("Nullable", "enable"), + new("PublishAot", "true"), + ]); + internal static readonly string TargetOverrides = """