1

I have a GitHub project for Visual Studio Ansible extension, in this extension I want to change icon of ansible file in Visual Studio (.ansible and .ansible.yaml) based on file extension, but I do not know How to do it?

Anybody know to How to do it?

I write extension for Visual Studio 2022

related to https://github.com/MicrosoftDocs/visualstudio-docs/issues/8966#issue-1588941743

Updated 2/17/2023

I think it is related to https://learn.microsoft.com/en-us/visualstudio/extensibility/internals/manifest-from-resources?view=vs-2022

and based on How to add custom icons to solution explorer in Visual Studio I try to add resources and image manifest, but my file display void instead of display correct icon, and I do not know my mistake

I update source code, that you have see it https://github.com/soroshsabz/visualstudio-ansible/tree/features/5-add-syntax

related to https://developercommunity.visualstudio.com/t/New-icon-for-custom-file-type-is-not-d/10283644

Dharman
  • 30,962
  • 25
  • 85
  • 135
sorosh_sabz
  • 2,356
  • 2
  • 32
  • 53
  • I understand your question that you like to administer or configure your Visual Studio in a way that for certain text files, which have just a file name extension .ansible a icon is display in the UI. Except from that and text files and file names can be named differently, there is nothing Ansible as well no programming at all within this question. Therefore it seems to be off-topic here. – U880D Feb 17 '23 at 08:29
  • No, you do not understand my question, I try to write extension for visual studio to support ansible domain specific language, so I want add icon for ansible file programmatically in my extension, so it is not off-topic – sorosh_sabz Feb 17 '23 at 08:33
  • related to https://stackoverflow.com/q/56630048/1539100 – sorosh_sabz Feb 17 '23 at 08:52
  • related to https://stackoverflow.com/q/50896478/1539100 – sorosh_sabz Feb 17 '23 at 08:53
  • @mads-kvist-kristensen Did you can see my problem? – sorosh_sabz Feb 17 '23 at 10:31
  • @1074470 Did you can see my problem? – sorosh_sabz Feb 17 '23 at 10:32
  • I only skimmed your code, but did you check if your package is actually being loaded? Set a breakpoint in AnsiblePackage on InitializeAsync. I make custom projects so my package is loaded when a project with matching extension is loaded. What triggers your package to load? – Manny Feb 17 '23 at 16:58
  • @Manny yes my package is loaded. (if my package does not loaded, icon of ansible file is like default empty file, but after I loaded my extension, the icon of ansible file is totaly blank. if you need we can upload my screenshot – sorosh_sabz Feb 17 '23 at 21:05
  • When I had that issue, all I did was add [ProvideBindingPath] attribute to the package class. I noticed you set your project up a bit different to mine as well. I used IProjectTreePropertiesProvider to change the icons in the tree. I also tested with KnownMonikers to determine if the error was in setting the icon or loading the image. Unfortunately, debugging VS extensions can be difficult and I gave up at one point on this issue. You may have to find a simple project that works and slowly change it to your needs, eventually finding the root cause. I have had to do this many times :( – Manny Feb 17 '23 at 21:59
  • @Manny as you can see in https://developercommunity.visualstudio.com/t/New-icon-for-custom-file-type-is-not-d/10283644 we change the `DefaultIconMoniker` with `KnownMonikers` all things it is work correctly, but using the GUID, it is now work correctly, I try `[ProvideBindingPath]` but my problem it is not resolved – sorosh_sabz Feb 18 '23 at 07:48
  • @Manny I try as sample with https://github.com/madskristensen/TomlEditor for Mads Kristensen, but as you can see in https://github.com/madskristensen/TomlEditor/issues/3 this project is not work too :( – sorosh_sabz Feb 18 '23 at 08:11

0 Answers0