Add --allow-prerelease and --no-sdk-version options to dotnet new globaljson template#54133
Add --allow-prerelease and --no-sdk-version options to dotnet new globaljson template#54133
Conversation
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/3a08d95c-8aa4-40b3-827d-65843a267b72 Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
|
Why does file generated with |
|
Hmm, I missed in the original request that you didn't even want an sdk value. The current behavior includes a default value for that. We could add a --no-sdk flag but then that would have to have error checking with --sdk-version. I'm not sure we'd want --sdk-version without a value to do that as that's most likely a typo (as I expect this to be the less common scenario). We could allow --sdk-version false and somehow make that not provide a version but that's a bit odd as version expects a version. @baronfel any thoughts on a direction to go to have allow-prerelease with no version? |
|
A |
|
@copilot can we add a --no-sdk-version option that won't include the SDK version as there is a scenario where a customer might want all-prerelease of false but not specify a version. |
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/bb7321e2-df28-4dc1-8781-6a48f9437b42 Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
Added dotnet new globaljson --allow-prerelease false --no-sdk-versionOutput: {
"sdk": {
"allowPrerelease": false
}
}The template conditional logic handles all combinations of |
|
@copilot when i'm testing this, I end up with an error creating the global.json and it ends halfway through. |
Agent-Logs-Url: https://github.com/dotnet/sdk/sessions/31064ea9-7627-4134-901b-89b936104671 Co-authored-by: marcpopMSFT <12663534+marcpopMSFT@users.noreply.github.com>
... Fixed in commit 4d1ae57. The root cause was that the template engine's |
dotnet new globaljsonhad no way to setallowPrereleasein the generatedglobal.json, requiring users to manually look up the field name and add it by hand. Additionally, the template always included an SDK version, preventing users from creating a minimalglobal.jsonwith onlyallowPrereleaseset.Template changes
AllowPrereleasechoice parameter ("true"/"false") totemplate.jsonwithdefaultValue: ""(omitted from output when unspecified — fully backward compatible) anddefaultIfOptionWithoutValue: "true"NoSdkVersionbool parameter totemplate.jsonwithdefaultValue: "false"— when set, the SDK version is omitted from the generatedglobal.json--allow-prereleaseand--no-sdk-versionCLI options indotnetcli.host.jsonrollForward,allowPrerelease,version)Usage
Output for
--allow-prerelease false:{ "sdk": { "allowPrerelease": false, "version": "9.0.100" } }Output for
--allow-prerelease false --no-sdk-version:{ "sdk": { "allowPrerelease": false } }Tests
AllCommonItemsCreatetest cases covering--allow-prerelease false,--allow-prerelease true, combined with--sdk-version,--no-sdk-versionalone, and--allow-prerelease false --no-sdk-versionglobaljsonhelp text snapshot to include both new options