TWT
TWT

Reputation: 2591

Include whole folder in VSIX

Is there an easy way to include a whole folder as content in a VSIX package? Hopefully there is an easier way than setting the "Include in VSIX" flag for each file separately.

The reason why we need this, is to add a compiled html help page (with a lot of dependency files) to our extension.

Upvotes: 0

Views: 2078

Answers (2)

IVNSTN
IVNSTN

Reputation: 9334

As an extra idea to the answer above: since .vsix is a regular .zip, you can unzip it, put your files inside, zip it back and rename into *.vsix - this will still work as a regular VSIX installer.

So the entire solution for building a vsix installer with additional files (e.g. output of other solution builds):

  1. Add a folder, e.g. Resources to your vsix project
  2. Put "blob" files included into this vsix project into this folder and set these options in Properties window:
    BuildAction = Content
    Inclide in VSIX = True
  1. Mention desired additional file extensions in csproj like that:
    <Content Include="Resources\*.json">
      <IncludeInVSIX>true</IncludeInVSIX>
    </Content>
    <Content Include="Resources\*.dll">
      <IncludeInVSIX>true</IncludeInVSIX>
    </Content>
    <Content Include="Resources\*.exe">
      <IncludeInVSIX>true</IncludeInVSIX>
    </Content>
  1. Put any dummy file with each extension (each mask mentioned in csproj) into this folder - so VS will understand that related option in csproj is not a broken/dummy string and will not ignore files with this extension later

  2. Build the VSIX solution

  3. Grab myproj.vsix file

  4. Rename it into myproj.zip, unzip

  5. Copy any files you need (with extensions/masks mentioned in csproj file) into Resources folder

  6. Zip all the stuff back into myproj.zip, rename it into myproj.vsix

  7. There you go: VSIX installer with a bunch of additional files needed for your installation. Install it.

  8. Put your VS version into this path and go there:

    cd %AppData%\Local\Microsoft\VisualStudio\14.0\Extensions\
  1. Locate your extension under subfolder named like 3xg44004asdf and check Resources subfolder contents - your files are there. Except files/file masks not mentioned in csproj even if they exist inside VSIX installer.

This scenario can be useful for building extensions for internal needs with TeamCity-like runner:

  1. Build VSIX dependencies
  2. Build VSIX
  3. Embed dependency artifacts into VSIX as described above
  4. Supply modified VSIX

Upvotes: 1

Leo Liu
Leo Liu

Reputation: 77006

Is there an easy way to include a whole folder as content in a VSIX package? Hopefully there is an easier way than setting the "Include in VSIX" flag for each file separately.

You can use wildcard * to include all the files under the folder as content into the VSIX package, like:

<Content Include="TestFolder\*.*">
  <IncludeInVSIX>true</IncludeInVSIX>
</Content>

After build the VSIX project, change the generated file .vsix to .zip and unzip it, we will find all the files in the TestFolder.

Hope this helps.

Upvotes: 2

Related Questions