简体   繁体   中英

What entry to make in .pkgdef for a .vsix Visual Studio Snippets Extension

I have a .vsix solution in Visual Studio 2017 for deploying 4 folders of snippets.

Here is what it looks like

Does each folder that has it's own xml or C# snippets need it's own .pkgdef file? Or do we just need a single .pkgdef file located directly under CompanySnippets?

I ask because we had one .pkgdef file with the following entries

[$RootKey$\Languages\CodeExpansions\CSharp\Paths]
"CompanyCodeSnippets"="$PackageFolder$"

[$RootKey$\Languages\CodeExpansions\Xml\Paths]
"CompanyCodeSnippets"="$PackageFolder$"

But we are getting unrecognized language problems for the snippets and I think I've troubleshot it down to the .pkgdef file.

If I make a seperate .pkgdef for each folder of snippets, I will get them to show up.

I'm confused on how to look at the value of $RootKey$, and what the $PackageFolder$ is really dowing. Not much documentation on these values other than what MS says they are. I was debugging VS 2017 and that should be at Registry Computer\\HKEY_CURRENT_USER\\Software\\Microsoft\\VisualStudio\\15.0 , but that registry has no Languages\\CodeExpansion, so I'm not sure if that is part of our problem.

And I'm also not sure if $PackageFolder$ is grabbing snippets from subfolders.

Any help is much appreciated.

Perhaps late to the party, but here's the official documentation on all the supported substitution strings in pkgdef files: https://docs.microsoft.com/en-au/visualstudio/extensibility/substitution-strings-used-in-dot-pkgdef-and-dot-pkgundef-files?view=vs-2015 .

A single pkgdef should be enough, but you'll most likely want to keep the C# and XML snippets in separate folders or else the snippets manager might be confused.

Here's how the corresponding part of your pkgdef should look like:

[$RootKey$\Languages\CodeExpansions\CSharp\Paths]
"CompanyCodeSnippets"="$PackageFolder$\CompanyCodeSnippets-CSharp"

[$RootKey$\Languages\CodeExpansions\Xml\Paths]
"CompanyCodeSnippets"="$PackageFolder$\CompanyCodeSnippets-Xml"

(apologies, cannot remember off the top of my head if one needs to escape the backslash characters in the paths)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM