Skip to content

dotnet project convert works incorrectly for target framework other than default base framework net10.0 #49177

Open
@egvijayanand

Description

@egvijayanand

Describe the bug

dotnet project convert works incorrectly for target framework other than default base framework net10.0

To Reproduce

A WinForms sample and it works correctly with dotnet run Forms.cs (assuming the file is saved as Forms.cs)

#:property TargetFramework net10.0-windows
#:property UseWindowsForms true
#:property OutputType WinExe

Application.Run(new Form() { Text = "Hello C#" });

When tried to convert it to a project with the command dotnet project convert Forms.cs, the output contains duplicated content.

The default property of the base target framework is always included which is incorrect and it should be based on the file input.

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net10.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <PropertyGroup>
    <TargetFramework>net10.0-windows</TargetFramework>
    <UseWindowsForms>true</UseWindowsForms>
    <OutputType>WinExe</OutputType>
  </PropertyGroup>

</Project>

Exceptions (if any)

None.

Further technical details

  • 10.0.100-preview.4.25258.110
  • CLI

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-run-fileItems related to the "dotnet run <file>" effortuntriagedRequest triage from a team member

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions