我发现以下文章很好地描述了如何将项目引用的PDB文件包含在VSIX软件包中:http://www.cazzulino.com/include-pdbs-in-vsix.html。
现在,我想做同样的事情,但是对于由项目引用生成的文档XML文件。我看到XML文件已经被复制到VSIX项目的输出目录中,但是我如何确保它们也被添加到.VSIX文件中?
答案 0 :(得分:0)
您可以通过在项目文件中使用VSIXSourceItem
或从单独的导入项目中使用它来添加所需的任何文件:
...
<!--You also can invoke this target before GetVsixSourceItems-->
<Target Name="ForceIncludeItems" AfterTargets="GetVsixSourceItems">
<ItemGroup>
<VSIXSourceItem Include="Path_to_your_xml_file" />
</ItemGroup>
</Target>
您还可以指定wildcards和功能来选择所需的特殊文件:
...
<VSIXSourceItem Include="*.xml" Condition="$([System.String]::new('%FileName)').StartsWith('My_start_with_pattern'))"/>
更简单但不太灵活的方法是将IncludeDocFilesInVSIXContainer
设置为true:
...
<IncludeDocFilesInVSIXContainer>true</IncludeDocFilesInVSIXContainer>
这样,目标将包含所有包含在@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>
答案 1 :(得分:0)
回答我自己的问题:
显然,还有一个“ DocumentationProjectOutputGroup”输出组。然后可以通过以下方式将此输出组添加到所有项目引用中:
<PropertyGroup>
<DefaultIncludeOutputGroupsInVSIX>
BuiltProjectOutputGroup;
DebugSymbolsProjectOutputGroup;
GetCopyToOutputDirectoryItems;
SatelliteDllsProjectOutputGroup;
BuiltProjectOutputGroupDependencies;
DocumentationProjectOutputGroup;
SatelliteDllsProjectOutputGroupDependencies
</DefaultIncludeOutputGroupsInVSIX>
</PropertyGroup>
<ItemDefinitionGroup>
<ProjectReference>
<IncludeOutputGroupsInVSIX>$(DefaultIncludeOutputGroupsInVSIX)</IncludeOutputGroupsInVSIX>
</ProjectReference>
</ItemDefinitionGroup>