Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please document how to change default console template. #26313

Closed
alexanderpino opened this issue Sep 29, 2021 · 61 comments · Fixed by #26338
Closed

Please document how to change default console template. #26313

alexanderpino opened this issue Sep 29, 2021 · 61 comments · Fixed by #26338
Assignees
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-fundamentals/svc Pri2

Comments

@alexanderpino
Copy link

alexanderpino commented Sep 29, 2021

Could you please document how we can change the console template back to the 'classic' Program + Main.

adegeo EDIT

We've opened up a new issue specifically for voting on how you feel about the templates. #27420


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@tdykstra
Copy link
Contributor

@adegeo @BillWagner

@tdykstra tdykstra added the doc-enhancement Improve the current content [org][type][category] label Sep 30, 2021
@dotnet-bot dotnet-bot removed the ⌚ Not Triaged Not triaged label Sep 30, 2021
@adegeo adegeo self-assigned this Sep 30, 2021
@KathleenDollard
Copy link
Contributor

KathleenDollard commented Sep 30, 2021

There is no direct way to do this in .NET 6. There are two approaches:

  • Copy the code that appears in this docs article.
    • Either leave out the usings or remove remove implicit usings from your project file
  • Target .NET 5 in your template, and then change the framework to .NET 6 in your project file after the project is created

We want feedback. Voting on this issue is one of the ways folks can provide feedback.

@tdykstra @BillWagner would you update the docs to indicate this, and let me know if you need anything from me.

@BillWagner
Copy link
Member

BillWagner commented Oct 1, 2021

For now, you can do this:

dotnet new console --framework net5.0

Or, any other older framework.

Then, you can change the TFM to .NET 6:

<TargetFramework>net6.0</TargetFramework>

@adegeo
Copy link
Contributor

adegeo commented Oct 1, 2021

Use

dotnet new console --framework net5.0 --target-framework-override net6.0

This will generate the old-style template but force the framework in the project to net6.0

@Walluce
Copy link

Walluce commented Oct 5, 2021

Can you please post a link to where I can vote against this new "feature"?

@svick
Copy link
Contributor

svick commented Oct 5, 2021

@Walluce If you want to suggest that the dotnet new console template should be changed, then the right repo would be dotnet/templating. There is already a somewhat related issue at dotnet/templating#3654.

If you think the whole feature of top-level programs should be removed, then in theory, the right repo would be dotnet/csharplang. But since that feature is not really new (it has been released in C# 9.0 almost a year ago), I don't think a vote against it would have any effect at this point.

@tdykstra
Copy link
Contributor

tdykstra commented Oct 5, 2021

@svick The article asks for feedback as up/down votes on this issue -- see the Template feedback section, The reference is to using top-level statements in the new-project template, not to the top-level statements feature itself.

@Walluce
Copy link

Walluce commented Oct 14, 2021

Use

dotnet new console --framework net5.0 --target-framework-override net6.0

This will generate the old-style template but force the framework in the project to net6.0

This doesn't work :(

@Walluce
Copy link

Walluce commented Oct 14, 2021

dotnet new web -n Demo -f net5.0 --target-framework-override net6.0 --no-https
For more information, run:
dotnet new web -h

@bynarie
Copy link

bynarie commented Oct 23, 2021

There is no direct way to do this in .NET 6. There are two approaches:

* Copy the code that appears in this docs article.
  
  * Either leave out the usings or remove remove implicit usings from your project file

* Target .NET 5 in your template, and then change the framework to .NET 6 in your project file after the project is created

We want feedback. Voting on this issue is one of the ways folks can provide feedback.

@tdykstra @BillWagner would you update the docs to indicate this, and let me know if you need anything from me.

In my opinion, this should be an optional global setting in visual studio. The new style template is ugly and I dont think anyone likes this. Thank you!

@dpugh
Copy link

dpugh commented Oct 29, 2021

Or provide a multiple .Net 6.0 frameworks (classic and simplified) that provide different initial layouts for the program.cs.

@lkmn-l9y
Copy link

That's too bad😅

@rposener
Copy link

Where are args in the new format? How do you use Command

Feels like this was not a well-informed decision to change the default template.

@hbrumleve
Copy link

It doesn't feel like the people who built this feature actually build a lot of software from scratch frequently. It feels like you're just showing off what you can do instead of building a tool for professionals to use. This adds several minutes to my startup time every time and takes me out of my flow.

@bynarie
Copy link

bynarie commented Nov 15, 2021

Yes, this really is complete shit. I just dont understand why this template was changed. Its not logical. I hope if we get enough people complaining it will change. And, per https://docs.microsoft.com/en-us/dotnet/core/tutorials/top-level-templates , this is the page it directs us to to voice our opinion about this template, so this is the correct spot.

@bravecobra
Copy link

Adding a boolean parameter to each of the templates that toggles between the toplevel statement syntax and the old syntax should be fairly easy. Just a matter of wrapping a few extra lines around the toplevel code. Leave it toplevel default checked if you want. I'll uncheck it myself.
Making old syntax harder to get back is certainly not creating good sentiment with a lot of developers.

The other alternative is writing an analyzer to detect the syntax and having a codefix to wrap the global syntax again. We do want to avoid the compile error having multiple entrypoints though.

@rfvan
Copy link

rfvan commented Nov 16, 2021

I agree with the sentiments of most of the others responding here - this is an awful change. Please give us a way to make the old template the default, and provide a "create invisible, magic, impossible to understand code-behind" setting for those who like the new template. This has made the simple console template virtually unusable without a lot of extra pushups.

@AlexeiScherbakov
Copy link

This template speed up project creating process, but it is completely useless.

  1. Application creation tooks less then 1% of all programming time
  2. Template does not have access to command line parameters
  3. Template hides function definition and return value logic (void no return value,int - return value stored in $LastExitCode PowerShell env var)

For me it is better to allow usage of global functions (it is allowed for C++/CLI)

int Main(string[] args)
{
    Console.WriteLine("Hello world");
}

@DiverBW
Copy link

DiverBW commented Nov 17, 2021

The current trend in technology seems to favaor PFM (pure freaking magic) and in my opinion makes it far harder for someone new to any given technology to understand what is really going on. This is a prime example.

As others have said, I would ask that you make this and option. I will certainly choose the option of the old style Program.cs file.

@ahwm
Copy link

ahwm commented Nov 17, 2021

Please provide an option to make the old style the default. I will go back to the old style every single time. The new style is not readable without experience.

@bravecobra
Copy link

I seriously apologize to everyone for my constant commenting and rants. Do we even have an explanation for why this template was changed? I'm legitimately not being sarcastic but actually asking. Thanks

Have a look at dotnet/csharplang#3117
None of these 3 reasons are valuable, desired or highly requested as far as I can see.

@bravecobra
Copy link

Funny how that issue is locked for comments for being "too heated".

@C1rdec
Copy link

C1rdec commented Nov 23, 2021

Any updates from Microsoft?

@Juniorsnet
Copy link

C# is becoming more close to python, whats next? run directly .cs files from command line?

@Kuinox
Copy link

Kuinox commented Nov 24, 2021

C# is becoming more close to python, whats next? run directly .cs files from command line?

I would use it a lot.
If I was given the choice with the old, and new template, I would use both.
What I dislike, is not having the choice of using the old template, and having to manually migrate the code.
The new template is nice to make littles C# script. I prefer using the old template for more serious apps.

@ahwm
Copy link

ahwm commented Nov 24, 2021

C# is becoming more close to python, whats next? run directly .cs files from command line?

https://github.com/dotnet/csharplang/blob/main/meetings/2021/LDM-2021-05-12.md#simple-c-programs

https://github.com/dotnet/designs/blob/a27fd42a68370f315bc2293dc748145f4075697f/proposed/simple-csharp-programs.md

@tdykstra tdykstra reopened this Nov 27, 2021
This was referenced Nov 27, 2021
@dongolojeno85
Copy link

This is confusing. Almost hit the wrong vote because the whole description is misleading.

"Template feedback
The top-level template is a new feature in .NET 6. Add an up or down vote GitHub issue #26313 to voice your support for this feature."
From https://docs.microsoft.com/en-us/dotnet/core/tutorials/top-level-templates

@Kuinox
Copy link

Kuinox commented Nov 30, 2021

Instead of "voting the new template", why can't we have both ?

@symbiotic
Copy link

symbiotic commented Dec 5, 2021

This is confusing. Almost hit the wrong vote because the whole description is misleading.

"Template feedback The top-level template is a new feature in .NET 6. Add an up or down vote GitHub issue #26313 to voice your support for this feature." From https://docs.microsoft.com/en-us/dotnet/core/tutorials/top-level-templates

Agreed. I suggest we redo the voting, in a new GitHub issue that does not conflict with the page asking for feedback. The page currently says "to voice your support for this feature", but this issue says "Could you please document how we can change the console template back to the 'classic' Program + Main". These votes are ambiguous.

This template is less usable, mainly because the arguments and return value are hidden.

I'm also concerned about the decision process at Microsoft, behind such a change making it into Visual Studio / .NET.

@tdykstra
Copy link
Contributor

tdykstra commented Dec 6, 2021

The comment in the templates article has been changed from:

The top-level template is a new feature in .NET 6. Add an up or down vote GitHub issue #26313 to voice your support for this feature.

to:

Top-level statements is a new feature in .NET 6. Add an up or down vote in GitHub issue #26313 to let us know if you support the use of this feature in project templates.

@adegeo
Copy link
Contributor

adegeo commented Dec 6, 2021

@tdykstra It may be better to open a new issue, I don't think any vote can be trusted 😁

@rfvan
Copy link

rfvan commented Dec 6, 2021

@tdykstra I agree with @adegeo - there are up and down votes splattered across many of the posts to this string and I suspect there was a lot of confusion as to which choice people were making. Please start a new issue with an unequivocal question so that it is completely clear what one is voting for or against.

@tdykstra
Copy link
Contributor

tdykstra commented Dec 6, 2021

Please start a new issue with an unequivocal question so that it is completely clear what one is voting for or against.

See #27420

@tdykstra tdykstra closed this as completed Dec 6, 2021
@rhrytskiv
Copy link

Please just add an option to choose if I want old or new style template instead of sdk switching this is very annoying.

@ahwm
Copy link

ahwm commented Dec 7, 2021

Please just add an option to choose if I want old or new style template instead of sdk switching this is very annoying.

@rhrytskiv see #27420 (comment)

@ghost
Copy link

ghost commented Dec 13, 2021

So..where is a nameSpace and class?

@died
Copy link

died commented Dec 13, 2021

Please just add an option to choose if I want old or new style template instead of sdk switching this is very annoying.

try this
https://marketplace.visualstudio.com/items?itemName=Doomdied.ClassicConsole1

@ghost
Copy link

ghost commented Dec 13, 2021

😂😂

@ghost
Copy link

ghost commented Dec 13, 2021

Thank you.

@tonysneed
Copy link

Made a suggested change to the docs with #28223.

@Earthman100
Copy link

Could you please document how we can change the console template back to the 'classic' Program + Main.

adegeo EDIT

We've opened up a new issue specifically for voting on how you feel about the templates. #27420

Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Name that Apptdykstra< Rest Api_curl -I https://api.github.com/users/octocat/orgs

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-enhancement Improve the current content [org][type][category] dotnet-fundamentals/svc Pri2
Projects
None yet
Development

Successfully merging a pull request may close this issue.