VSIX-如何在包中包含XML文档文件



我发现以下文章很好地描述了如何将项目引用的PDB文件包含在VSIX包中:http://www.cazzulino.com/include-pdbs-in-vsix.html.

现在我想做同样的事情,但对于由项目引用生成的文档XML文件。我看到XML文件已经被复制到VSIX项目的输出目录中,但我如何确保它们也被添加到.VSIX文件中呢?

您可以通过在项目文件中使用VSIXSourceItem或从单独导入的项目中使用它来添加任何您想要的文件:

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

您还可以指定通配符和函数来选择您想要的特殊文件:

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

更简单但不太灵活的方法是将IncludeDocFilesInVSIXContainer设置为true:

...
<IncludeDocFilesInVSIXContainer>true</IncludeDocFilesInVSIXContainer>

通过这种方式,target将包括所有作为@DocFileItem包含的项(正如我所知,默认情况下,它只包含vsix项目本身的xml文件(。

因此,要添加除被vsix构建包抑制之外的所有xml文件,您需要手动添加它们:

...
<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>

回答我自己的问题:

显然还有一个"DocumentationProjectOutputGroup"输出组。然后可以通过以下方式将该输出组添加到所有项目引用中:

<PropertyGroup>
<DefaultIncludeOutputGroupsInVSIX>
BuiltProjectOutputGroup;
DebugSymbolsProjectOutputGroup;
GetCopyToOutputDirectoryItems;
SatelliteDllsProjectOutputGroup;
BuiltProjectOutputGroupDependencies;
DocumentationProjectOutputGroup;
SatelliteDllsProjectOutputGroupDependencies
</DefaultIncludeOutputGroupsInVSIX>
</PropertyGroup>
<ItemDefinitionGroup>
<ProjectReference>
<IncludeOutputGroupsInVSIX>$(DefaultIncludeOutputGroupsInVSIX)</IncludeOutputGroupsInVSIX>
</ProjectReference>
</ItemDefinitionGroup>

相关内容

  • 没有找到相关文章

最新更新