Disable .NET 6 top-level statements on ConsoleApp

How to return old console style, like in .NET 5.0? Visual Studio has disable-button.I love old style.

1
12 comments

Hello, there is no such option in Rider. There is a corresponding issue on our tracker: RIDER-79136. As a workaround, I can suggest creating a solution that targets .NET 5 and then changing target.

0

HI, the given advice to use SDK5 then change to SDK6 no longer works!

I have just hit this exact thing, I want to NOT TURN ON top level statements in a .NET 6 console app and there is no option.

If I create my app as an SDK5 app, I get what's expected:

BUT, if I then go into my properties, there is NO .NET 6 option

.NET 6 is definitely installed on my machine, because I'm allowed to choose it when creating a new project:

When can we get this option added?

 

1

Hello Shawty,

This feature is not yet implemented. We have a corresponding issue on our bug tracker. It has not been planned yet. We would appreciate it if you would upvote the issue in order to demonstrate additional interest and bring increased awareness to the issue.

If you have any other questions, do not hesitate to ask. Have a great day!

0

Already upvoted :-)  5 mins after I originally posted this.

I just also wanted to make a point that the old way of creating an SDK5 then switching to 6 advice you've been using as a workround no longer works.

0

Can you edit the csproj and remove the

<ImplicitUsings>enable</ImplicitUsings>

setting - does that work?

0

Tim Barrass, yes and no.

All that setting does is disable the feature in your project, so that if anyone then tries to create a top level file without the required boiler plate, the compiler will complain.

What we are talking about here in this thread is having the option in the IDE to enable/disable this at project creation time (IE: before csproj is even created)

 

0

Yes, it's a workaround, not a fix, but it helps anyone waiting for the fix.

0

I agree Tim, but it still means that when you create a new project, you have no choice but to create a project that has only the one top line statement in your program.cs file, and thus have to sit and write all the old boiler plate back in by hand.

 

0

This worked for me. Created the project manually from command prompt

dotnet new worker -n testworker --use-program-main

 

1

I am going back to visual studio because of this issue. This is ludicrous.

0

Hello Thomas,

Apologies for the inconvenience. We hope to address this issue in future releases. There will be new project creation dialog. Option to avoid top-level statements will be there.

https://youtrack.jetbrains.com/issue/RIDER-79136/New-project-dialog-option-to-avoid-top-level-statements

Have a nice day!

0

I have created project on Visual Studio with low-level. Then open this project with Rider. :)

1

Please sign in to leave a comment.