Search code examples
visual-studio-2022visual-studio-extensionsvsixmanifest

How to properly set Icon and license file in vsixManifest file?


I've just published my first visual studio extension and having some problems with setting the Icon and license file to the source.extension.vsixmanifest file.

I've tried googling and getting help from AI tools such as ChatGPT and Claude.Ai but nothing I do seems to help.
I've created the project using the Code refactoring (.Net standard) template, which generates two projects - one for the code and one for the vsix, and manually changed just a few things in the vsixManifest file. Here's the current file:

<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
  <Metadata>
    <Identity Id="AutoEntityGenerator..3633938B-4D62-4E7A-92C3-BCBBD5DEEFE6"
              Version="1.0.0"
              Language="en-US"
              Publisher="Zohar Peled"/>
    <DisplayName>AutoEntityGenerator</DisplayName>
    <Description xml:space="preserve">Automatically generates DTO and mapping classes based on your domain entities.</Description>
    <Icon>AutoEntityCreator.png</Icon>
  </Metadata>
  <Installation>
    <InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[16.0,17.0)">
      <ProductArchitecture>x86</ProductArchitecture>
    </InstallationTarget>
    <InstallationTarget Id="Microsoft.VisualStudio.Community" Version="[17.0,)">
      <ProductArchitecture>amd64</ProductArchitecture>
    </InstallationTarget>
  </Installation>
  <Dependencies>
    <Dependency Id="Microsoft.Framework.NDP" DisplayName="Microsoft .NET Framework" d:Source="Manual" Version="[4.5,)" />
  </Dependencies>
  <Assets>
    <Asset Type="Microsoft.VisualStudio.MefComponent" d:Source="Project" d:ProjectName="AutoEntityGenerator" Path="|AutoEntityGenerator|"/>
  </Assets>
  <Prerequisites>
    <Prerequisite Id="Microsoft.VisualStudio.Component.CoreEditor" Version="[15.0,)" DisplayName="Visual Studio core editor" />
    <Prerequisite Id="Microsoft.VisualStudio.Component.Roslyn.LanguageServices" Version="[15.0,)" DisplayName="Roslyn Language Services" />
  </Prerequisites>
</PackageManifest>

When I attempt to add the <License> tag, I get the following warning:

The element 'Metadata' in namespace 'http://schemas.microsoft.com/developer/vsx-schema/2011' has invalid child element 'License' in namespace 'http://schemas.microsoft.com/developer/vsx-schema/2011'. List of possible elements expected: 'PreviewImage, Tags, Preview, Version' in namespace 'http://schemas.microsoft.com/developer/vsx-schema/2011' as well as any element in namespace '##other'.

I've tried updating the Microsoft.VSSDK.BuildTools package (currently installed 17.10.2185, tried updating to the latest available version which is 17.11.414) but gut an error from nuget:

Unable to find package Microsoft.VisualStudio.SDK.Analyzers with version (>= 17.7.41)

  • Found 28 version(s) in nuget.org [ Nearest version: 17.7.32 ]

As for the Icon - I've double checked, the icon file appears in the bin/release directory with the correct name, it's a valid png file bot for some reason I can't get it to show in the visual studio's extensions menu's installed tab.


Solution

  • Did you add the <License> tag in VSIX Manifest Designer?

    If the file does not contain valid XML, the manifest designer won't open. Please check whether you can open the designer after adding <License>.

    Unable to find package Microsoft.VisualStudio.SDK.Analyzers with version (>= 17.7.41)

    I am able to reproduce the same error when i update package Microsoft.VSSDK.BuildTools to 17.11.414.

    When i checked the Dependencies of the package from nuget websites, it notes that Microsoft.VSSDK.BuildTools depends on Microsoft.VisualStudio.SDK.Analyzers (>= 17.7.41). However the latest version of Microsoft.VisualStudio.SDK.Analyzers is 17.7.32. This may cause the NU1102 error: unable to find packageg xxx. Microsoft.VSSDK.BuildTools Microsoft.VisualStudio.SDK.Analyzers

    I suggest you can click report package on nuget org.

    However based on my test, when i build the VSIX project, the build seems ignores the nuget package error and displays success. Test

    When i checked the "bin/release" folder, the icon file and license file appear there. After packaging the extension, go to the Tools menu and click Extensions and Updates. The TestPublish extension appears in the center pane with icon. enter image description here

    Hope it can help you.

    Update by Zohar:

    After our conversation in the comments, I've added a new project to my solution using the Empty VSIX Project template, where I could use the vsixManifest designer. Then I've edited the vsixmanifest in this project with the relevant details and removed the project that contained the old vsixManifest.

    This solved the problem for me.