You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Feature Request: Ability to set default language for dotnet new #4950
Now that there are several commands, dotnet repl and dotnet new, that supports language arguments, I think it makes sense to be able to somehow specify a default language.
If you primarily work with F# projects, I think it'd be nice to not have to specify --lang fsharp every time you want to create a new project or start the repl.
Is there an existing configuration mechanism in place?
I propose a simple DOTNET_DEFAULT_LANGUAGE environment variable that you can set to [c#|cs|csharp|f#|fs|fsharp].
Here's a potential problem with an environment variable:
Who reads it? If you think about the set of things that need to know about that setting, VS tools, Omnisharp, the CLI itself. Any API that wants to reason about the project data.
Project to project references can be multi language and not having the language in the project file assumes that all projects have the same language (today C# is hardcoded as the fallback when nothing is specified).
A better solution would be to have things declared in global.json and inherited by default in the project.json file.
Who reads it? If you think about the set of things that need to know about that setting, VS tools, Omnisharp, the CLI itself. Any API that wants to reason about the project data
dotnet-new and dotnet-repl, only these tools
Tools can just pass the argument --lang or similar if need specific language
Project to project references
i think project.json it's ok with compilerName, we use "compilerName": "fsc" so it's ok
I think default compilerName to c# it's not a problem, in F# we can explicit set it in project.json
It'll be exactly the same as DOTNET_BUILD_VERSION and DOTNET_ASSEMBLY_FILE_VERSION (here).
Agreed it's the same. The difference is that the IDE and tool chain don't really need to know about those since it shells out to the command line to produce a build. You could imagine having a property page setting tool environment.
This suggestion was specific for the CLI, not something that VS, OmniSharp etc. would read. They can provide their own defaults.
That's not a great experience. The CLI consists of a set of command line tools and libraries that all need to work together. When we designed the DNX we made sure to keep the systems that all need to read data in sync so that things always worked in editors and IDEs and APIs.
Another example of this is passing the packages folder on the command line to dotnet restore. It's perfectly reasonable to do that but if you do choose to do it, dotnet build would break, omnisharp and VS would break and the runtime would break. Thats why nuget.config and global.json work better in the general case.
but global.json need to exists before i can do dotnet new or repl
I cannot open a prompt and do dotnet new in a specific folder, i need to copy the global.json.
If like that, it's better dotnet new fsharp/console or dotnet new console --lang f#
What if the environment variable was a default for dotnet new? Is that what we're talking about? I was under the impression that we were changing the default language without specifying any language in the file. If this is just a way to avoid the command line arg then it's fine.
@BlackDwarf f# works on Windows, project.json is ok, dotnet cli too.
This issue it's about reading an env var DOTNET_DEFAULT_LANGUAGE so dotnet new use the language of this env var as default. if not set the default is c#, the current behaviour
It's really useful, to stop continue to write --lang f# for f# users (and vb too)
DOTNET_DEFAULT_LANGUAGEaffect only dotnet new. The others commands are ok already. Maybe dotnet repl can read it too, but it not needed atm
@BlackDwarf if the idea of DOTNET_DEFAULT_LANGUAGE it's ok, pls write an ok there so someone can implement it. It's a really nice up-for-grab
changed the title [-]Feature Request: Ability to set default language[/-][+]Feature Request: Ability to set default language for dotnet new[/+]on Nov 10, 2016
Activity
enricosada commentedon Jan 29, 2016
👍 i can implement it, if it's approved
I think only
dotnet newanddotnet replshould use it, the other commands doesnt required a lang argument as input.example of current commands (or future discussed improvement):
dotnet new fsharp/console( my next pr as discussed in dotnet-new enhancements #4695 )dotnet repl f#( i think we can use argument instead of--lang)khellang commentedon Jan 29, 2016
Yeah, I was kinda just filing an issue before sending a PR, just to make sure I don't do any unnecessary work...
enricosada commentedon Jan 29, 2016
@khellang sure, better to discuss about it before pr 😄
I wrote about implement it because it's something i really like to use, no need to wait ms
davidfowl commentedon Jan 29, 2016
Here's a potential problem with an environment variable:
A better solution would be to have things declared in
global.jsonand inherited by default in theproject.jsonfile.enricosada commentedon Jan 29, 2016
dotnet-newanddotnet-repl, only these toolsTools can just pass the argument
--langor similar if need specific languagei think
project.jsonit's ok withcompilerName, we use"compilerName": "fsc"so it's okI think default
compilerNametoc#it's not a problem, in F# we can explicit set it inproject.jsondavidfowl commentedon Jan 29, 2016
The main point was trying to explain why an environment variable doesn't work as well as you would think.
khellang commentedon Jan 29, 2016
It'll be exactly the same as
DOTNET_BUILD_VERSIONandDOTNET_ASSEMBLY_FILE_VERSION(here).That's why I asked:
If you think this would be a better place for it and make the CLI read that, it's fine for me.
This suggestion was specific for the CLI, not something that VS, OmniSharp etc. would read. They can provide their own defaults.
davidfowl commentedon Jan 29, 2016
Agreed it's the same. The difference is that the IDE and tool chain don't really need to know about those since it shells out to the command line to produce a build. You could imagine having a property page setting tool environment.
That's not a great experience. The CLI consists of a set of command line tools and libraries that all need to work together. When we designed the DNX we made sure to keep the systems that all need to read data in sync so that things always worked in editors and IDEs and APIs.
Another example of this is passing the packages folder on the command line to
dotnet restore. It's perfectly reasonable to do that but if you do choose to do it,dotnet buildwould break, omnisharp and VS would break and the runtime would break. Thats whynuget.configandglobal.jsonwork better in the general case.enricosada commentedon Jan 29, 2016
but global.json need to exists before i can do
dotnet neworreplI cannot open a prompt and do
dotnet newin a specific folder, i need to copy the global.json.If like that, it's better
dotnet new fsharp/consoleordotnet new console --lang f#davidfowl commentedon Jan 29, 2016
What if the environment variable was a default for dotnet new? Is that what we're talking about? I was under the impression that we were changing the default language without specifying any language in the file. If this is just a way to avoid the command line arg then it's fine.
khellang commentedon Jan 29, 2016
Yes, that's it. Just a simple way to "always pass
--lang fsharp" 😁davidfowl commentedon Jan 29, 2016
As long as the language ends up in the project file then we're fine. I thought the point was to avoid that.
enricosada commentedon Jan 29, 2016
sure, np about
projectfiles.i think it's better to have explicit
compilerName: fscin project.json, we dont want to change thatit's to avoid in
dotnet newanddotnet replonlyshahid-pk commentedon Jan 29, 2016
👍 yes plz
thesmithee commentedon Feb 25, 2016
@enricosada is the fix in? I think we do have the language information in the
project.jsonnow, correct?enricosada commentedon Feb 25, 2016
@BlackDwarf f# works on Windows,
project.jsonis ok, dotnet cli too.This issue it's about reading an env var
DOTNET_DEFAULT_LANGUAGEsodotnet newuse the language of this env var as default. if not set the default is c#, the current behaviourIt's really useful, to stop continue to write
--lang f#for f# users (and vb too)DOTNET_DEFAULT_LANGUAGEaffect only dotnet new. The others commands are ok already. Maybedotnet replcan read it too, but it not needed atm@BlackDwarf if the idea of
DOTNET_DEFAULT_LANGUAGEit's ok, pls write an ok there so someone can implement it. It's a really niceup-for-grabTheRealPiotrP commentedon Jul 27, 2016
@mlorbetske @livarcocc something to consider in your
dotnet newwork.[-]Feature Request: Ability to set default language[/-][+]Feature Request: Ability to set default language for dotnet new[/+]khellang commentedon Feb 8, 2017
Why was this closed? I see no linked PR that fixes this... 😕
enricosada commentedon Feb 8, 2017
I'll reopen in dotnet/templating. But i see in global.json a property :)
enricosada commentedon Feb 8, 2017
@khellang there is dotnet/templating#115 about that
TheRealPiotrP commentedon Feb 9, 2017
Thanks @enricosada. I closed as the original
dotnet newis no more, replaced by the templating implementation. Glad you moved this over :)