Visual Studio的包到WP8 XAP不必要的XML文档文件不必要、文档、文件、Studio

2023-09-04 01:40:36 作者:不是客观却伤了小姐的心、

如果您创建的Windows Phone 8应用程序在Visual Studio和引用任何库或从的NuGet提供的XML文档文件手动,Visual Studio将自动打包这些XML文件转换为输出XAP为好。

If you create Windows Phone 8 App in Visual Studio and reference any libs with XML documentation files supplied from nuget or manually, Visual Studio will automatically pack those XML files into output XAP as well.

在我们的情况下,这种怪异的行为的Visual Studio中增加XAP大小几乎两倍。 (我们在总的XML文档8MB的。)

In our case this weird behavior of Visual Studio increases XAP size almost twice. (We have 8Mb of xml docs in total.)

没有为WP7应用程序的项目没有这样的问题。

There is no such problem for WP7 app projects.

如何通过强制的Visual Studio不收拾不必要的文档文件,以减少XAP文件的大小?

How to reduce the size of the xap file by forcing Visual Studio not to pack unnecessary documentation files?

更新14/02/2013:

步骤来重现问题:

在使用Visual Studio创建Windows Phone 8的应用程序项目 在参考无扩展 - 主图书馆使用的NuGet包管理器 生成解决方案 转到Bin文件夹并解压XAP存档

您会发现有许多像System.Reactive.Core.xml

You will find there lots of unnecessary XML doc files like "System.Reactive.Core.xml"

我相信这是安全问题,因为如果启用了XML文档生成你的项目(或在溶液中的其他项目),这些XML文档被打成XAP以及 - 这是极不可取的,当任何人都可以阅读评论到您的code。

I believe this is security issue, because if you enable XML doc generation for your project (or other projects in solution), those XML docs will be packed into XAP as well – this is highly undesirable when anyone may read comments to your code.

推荐答案

更新于20/02/2013

作为@ A-学生指出,在评论中,我的previous解决方案会迫使您添加的MSBuild东西在每一个项目中的一个解决方案。

As @A-student pointed out in the comments, my previous solution would force you to add the MSBuild stuff in each and every project in a solution.

这一次只需要你输入的项目实际上有一个XAP / APPX文件输出:

This one only requires you enter it on the projects that actually have a XAP/APPX file output:

<PropertyGroup>
  <FilesToXapDependsOn>$(FilesToXapDependsOn);AfterFilesToXapDependsOn</FilesToXapDependsOn>
</PropertyGroup>
<Target Name="AfterFilesToXapDependsOn">
  <ItemGroup>
    <FilteredPackagingOutputs Remove="@(FilteredPackagingOutputs)" Condition="'%(FilteredPackagingOutputs.OutputGroup)' == 'CopyLocalFilesOutputGroup' AND '%(FilteredPackagingOutputs.Extension)' == '.xml'" />
  </ItemGroup>
</Target>

这是一个黑客位的,应谨慎使用(不知道现在什么影响,这可能实际上有),但似乎做的工作完全现​​在!

It's a bit of a hack and should be used carefully (not sure right now of what implications this might actually have), but seems to do the job perfectly for now!