TWT
TWT

Reputation: 2591

VSIX - How to include XML documentation files in package?

I've found the following article that nicely describes how PDB files of project references can be included in the VSIX package: http://www.cazzulino.com/include-pdbs-in-vsix.html.

Now I would like to do the same, but for documentation XML files that are generated by project references. I see that the XML files are already copied to the output directory of the VSIX project, but how can I make sure that they are added to the .VSIX file as well?

Upvotes: 0

Views: 590

Answers (2)

TWT
TWT

Reputation: 2591

Answering my own question:

Apparently there is also a "DocumentationProjectOutputGroup" output group. This output group can then be added to all project references in the following way:

<PropertyGroup>
    <DefaultIncludeOutputGroupsInVSIX>
        BuiltProjectOutputGroup;
        DebugSymbolsProjectOutputGroup;
        GetCopyToOutputDirectoryItems;
        SatelliteDllsProjectOutputGroup;
        BuiltProjectOutputGroupDependencies;
        DocumentationProjectOutputGroup;
        SatelliteDllsProjectOutputGroupDependencies
    </DefaultIncludeOutputGroupsInVSIX>
</PropertyGroup>

<ItemDefinitionGroup>
    <ProjectReference>
        <IncludeOutputGroupsInVSIX>$(DefaultIncludeOutputGroupsInVSIX)</IncludeOutputGroupsInVSIX>
    </ProjectReference>
</ItemDefinitionGroup>

Upvotes: 1

George Alexandria
George Alexandria

Reputation: 2936

You can add anything file that you want by using VSIXSourceItem in your project file or using it from the separate imported project:

...
<!--You also can invoke this target before GetVsixSourceItems-->
<Target Name="ForceIncludeItems" AfterTargets="GetVsixSourceItems"> 
  <ItemGroup>
    <VSIXSourceItem Include="Path_to_your_xml_file" />
  </ItemGroup>
</Target>

Also you can specify wildcards and functions to select a special files which you want:

...
<VSIXSourceItem Include="*.xml" Condition="$([System.String]::new('%FileName)').StartsWith('My_start_with_pattern'))"/>

More easy but less flexible way is setting IncludeDocFilesInVSIXContainer to true:

...
<IncludeDocFilesInVSIXContainer>true</IncludeDocFilesInVSIXContainer>

In this way target will include all items which were included as @DocFileItem (as I know, by default it's only include xml file for vsix project itself).

So to add all xml files excluding suppressed by vsix build package you need to add them manually:

...
<IncludeDocFilesInVSIXContainer>true</IncludeDocFilesInVSIXContainer>

...
<Target Name="AppendNonSuppressXml" AfterTargets="GetVsixSourceItems">
    <ItemGroup>
      <SuppressXml Include="@(SuppressFromVsix->'%(FileName)')" /> <!-- store all suppressed assemblies names to avoid copying their xml files-->
    </ItemGroup>
    <PropertyGroup>
      <SuppressAsString>$([System.String]::Join(';', @(SuppressXml))</SuppressAsString> <!-- use to emulate Collections.Contains(item)-->
    </PropertyGroup>
    <ItemGroup>
      <!-- assume that xml files will be received from ReferenceCopyLocalPaths, you can use another source -->
       <VSIXSourceItem 
        Include="@(ReferenceCopyLocalPaths)"
        Condition="$(IncludeDocFilesInVSIXContainer) And '%(ReferenceCopyLocalPaths.Extension)' =='.xml' 
         And !($([System.String]::new($(SuppressAsString)).Contains('%(ReferenceCopyLocalPaths.FileName)')))" />
    </ItemGroup>
</Target>

Upvotes: 1

Related Questions