Closed JohanPetersson closed 2 years ago
There is some caching bug that I ran into recently. I’m thinking you are running into the same. You shouldn’t need an ide.host.json anymore for VS2022. Try this, uninstall your template, copy your template to another folder and then install from that new location. Does it work after that?
Filing bugs here for now is ok. After we figure it out we can move it if needed.
You shouldn’t need an ide.host.json anymore for VS2022.
@sayedihashimi I noticed that template.json
had a new displayName
for symbols, so I switched over to that instead of ide.host.json
but I still use ide.host.json
for isVisible
. Are you saying everything is visible now by default and we don't need ide.host.json
?
If true I think I still need ide.host.json
for these settings:
{
"order": 0,
"learnMoreLink": "https://github.com/Dotnet-Boxed/Templates/blob/main/Docs/Orleans.md",
"icon": "icon.png"
}
But can remove all symbolInfo
:
"symbolInfo": [
{
"id": "Title",
"isVisible": true
},
...
]
Exited VS, cleared cache, uninstalled template, moved nupgk to different location, and installed. No difference. As I mentioned, other changes in the template do work, so I know that the some things are not cached at least.
Here's the complete template (with some info replaced with 'xxx')
{
"$schema": "http://json.schemastore.org/template",
"author": "xxx",
"sourceName": "Cms.Empty",
"classifications": [ "Web" ],
"identity": "xxx",
"name": "xxx",
"shortName": "xxx-cms-empty",
"description": "Empty web application with xxx CMS",
"tags": {
"language": "C#",
"type": "project"
},
"sources": [
{
"modifiers": [
{
"condition": "(!enablelDocker)",
"exclude": [
"Directory.Build.props",
"docker-compose.yml",
"Docker/**/*"
]
}
]
}
],
"symbols": {
"enablelDocker": {
"type": "parameter",
"datatype": "bool",
"defaultValue": "false",
"description": "Enable Docker support"
},
"saPassword": {
"type": "parameter",
"datatype": "string",
"defaultValue": "Qwerty12345!",
"description": "Password for the SA database account",
"replaces": "Qwerty12345!"
}
}
}
I've noticed all examples are using pascal casing on symbols, could that be the issue here?
@RehanSaeed
@sayedihashimi I noticed that template.json had a new displayName for symbols, so I switched over to that instead of ide.host.json but I still use ide.host.json for isVisible. Are you saying everything is visible now by default and we don't need ide.host.json?
No need for isVisible
any more. By default all parameters will be displayed. You can create a host file to hide parameters if needed.
If true I think I still need ide.host.json for these settings:
For the learn more link, you'll need the host file. For the icon, you can drop the icon.png
and it will get picked up. One thing that I'm not sure of, if you have a host file you may need to define the icon there. If you could try it and let me know that would be great. I can add that detail to the readme.
@JohanPetersson can you share your template? It will be much easier for me to diagnose it if I can try it. If you can't share it here, you can share it with me privately by emailing me at sayedha [AT] MICROSOFT.
I've emailed you Sayed. Thanks for taking your time and looking into this.
No need for isVisible any more. By default all parameters will be displayed. You can create a host file to hide parameters if needed.
I tried removing all symbols in ide.host.json
but kept the file to set the order
, learnMoreLink
and icon
properties and my symbols no longer show up in VS 2022 Preview except the Framework symbol.
I tried removing all symbols in ide.host.json but kept the file to set the order, learnMoreLink and icon properties and my symbols no longer show up in VS 2022 Preview except the Framework symbol.
@phenning is that expected with the current bits?
@JohanPetersson I have replied to your email, we can continue our discussion on email. For other folks looking at this issue, I believe Johan is running into this bug https://github.com/dotnet/templating/issues/4155.
The default if behavior if an ide.host.json is specified is to NOT opt in symbols which are not specified in symbolInfo by default.
However, you can add "defaultSymbolVisibility": true
to the host file to enable all the symbols even if no symbolInfo is configured. in the case where you don't need to override the text or defaults in Visual Studio. This can be combined with explictly adding a symbolInfo section and disabling certain symbols via isVisible: false, or modifying their default value or display text.
The complete behavior is as follows.
For no host file:
If host file is present:
Thanks @phenning, I will get those details added to the readme here soon.
One note I found from the PR comment I made when I checked this in that may explain the complexity here:
"Note that we cannot treat defaultSymbolVisibility to be true in the cases when a symbol info is not present due to ASP.NET Core templates not specifically excluding most of their symbols."
We ended up erring on the side of not showing parameters if we thought existing templates could potentially expose too many parameters in Visual Studio and make the experience confusing for template consumers.
I'm happy with your answers and it has resolved my issues now. Closing the issue. Thank you so much.
For anyone that comes back, the issue was relating to caching. If you are installing with a folder path, workaround is to copy the folder to another folder and install. If you are installing via .nupkg file, change the version number. Hopefully we can get a better workaround soon.
@phenning when you have a chance, please review my changes to readme to ensure that I didn't misstate anything https://github.com/sayedihashimi/template-sample/commit/1d627e6489a065a21548d7c23a78843c32b14f07.
I've tried @phenning's suggestion and used "defaultSymbolVisibility": true
in my ide.host.json
files while removing all "isVisible": true
. However, I'm finding that it only works (options show up in VS) for my NuGet template and not the other API, GraphQL and Orleans templates.
Am I doing something wrong, is there a bug?
@RehanSaeed is the NuGet template the only one with a framework symbol in template.json? Did the other templates work when the symbolInfos re explicit?
@phenning Yes thats correct!
Can you see if adding a Framework symbol to one of the other templates results in the expected behavior for the other symbols?
It looks like a bug which results in the Additional Information page being skipped if there is no Framework Symbol and zero explicitly enabled symbols.
You may also be able to just define a single symbolInfo for just one of your symbols in order to work around the bug. This would be instead of adding a Framework symbol.
@phenning Just tested and adding a Framework
symbol does work. Adding a single symbolInfo
also works and it doesn't matter if the symbolInfo.isVisible
is true or false.
Post actions are not run in Visual Studio (any plans to change that???), so I ended up having to include some symbolInfo
's to hide options to skip running them e.g. I have an option to skip opening a TODO.html file.
So this is a closed item however i am having this same exact issues in VS for Mac. I have it updated to latest codeset, i have looked over many samples/tutorials/MS Docs and parameters will not show on the form when creating a project from a template.
template.json file
{
"$schema": "http://json.schemastore.org/template",
"author": "",
"classifications": [ "Web" ],
"identity": "",
"name": "",
"groupIdentity": "",
"shortName": "mymvc",
"sourceName": "Template.MVC",
"tags": {
"language": "C#",
"type": "project"
},
"preferNameDirectory": true,
"symbols": {
"ClientId": {
"type": "parameter",
"dataType": "string",
"displayName": "AzureAD Application (client) ID",
"defaultValue": "00000000-0000-0000-0000-000000000000",
"replaces": "__CLIENTID__"
},
"TenantId": {
"type": "parameter",
"dataType": "string",
"displayName": "AzureAD Directory (tenant) ID",
"defaultValue": "00000000-0000-0000-0000-000000000000",
"replaces": "__TENANTID__"
},
"ClientSecret": {
"type": "parameter",
"dataType": "string",
"displayName": "AzureAD Client Secret",
"defaultValue": "00000~0000000000000000000000000000000000",
"replaces": "__CLIENTSECRET__"
},
"ApiScopes": {
"type": "parameter",
"dataType": "string",
"displayName": "API Scopes (space delimited)",
"defaultValue": "user.read",
"replaces": "__APISCOPES__"
},
"SkipRestore": {
"type": "parameter",
"datatype": "bool",
"description": "If specified, skips the automatic restore of the project on create.",
"defaultValue": "false"
}
},
"postActions": [
{
"condition": "(!skipRestore)",
"description": "Restore NuGet packages required by this project.",
"manualInstructions": [
{ "text": "Run 'dotnet restore'" }
],
"actionId": "210D431B-A78B-4D2F-B762-4ED3E3EA9025",
"continueOnError": true
}
]
}
ide.host.json file
{
"$schema": "http://json.schemastore.org/vs-2017.3.host",
"name": { "text": "My MVC" },
"description": { "text": "This will allow one to make an MVC application that has all the wire-ups to start an application." },
"icon": "icon.png",
"tags": [
{
"type": "platform",
"add": [ "C#", "MVC", "AzureAD" ]
}
],
"symbolInfo": [
{
"id": "ClientId",
"name": { "text": "Client Id" },
"isVisible": true
},
{
"id": "TenantId",
"name": { "text": "Tenant Id" },
"isVisible": true
},
{
"id": "ClientSecret",
"name": { "text": "Client Secret" },
"isVisible": true
},
{
"id": "ApiScopes",
"name": { "text": "Azure AD Api Scopes (space delimited)" },
"isVisible": true
},
{
"id": "SkipRestore",
"isVisible": false,
}
]
}
Not sure where to log these issues, please point me to correct repo if this is not the correct place.
Parameters are not showing up in VS2022. I install my template from a local NuGet package, I'm clearing the cache (.templateengine) between installs and also exit all VS instances before clearing the cache. I've also created an ide.host.json file with the parameters to see if that made any difference, but with no luck (the schema for ide.host.json seems to be outdated http://json.schemastore.org/vs-2017.3.host). All other changes I make to the template, such as new or changed files, does work. The template fulfills all other requirements you mention here.
These are my symbols in template.json
and ide.host.json
What have I missed?