Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio packs into WP8 XAP unnecessary XML doc files

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.

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

There is no such problem for WP7 app projects.

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

Update 14/02/2013:

Steps to reproduce the issue:

  1. Create Windows Phone 8 App project using Visual Studio
  2. Reference “Reactive Extensions – Main Library” using NuGet package manager
  3. Build solution
  4. Go to Bin folder and unpack XAP archive

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

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.

like image 940
A-student Avatar asked Feb 13 '13 08:02

A-student


1 Answers

Updated on 20/02/2013

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.

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!

like image 197
Pedro Lamas Avatar answered Oct 06 '22 23:10

Pedro Lamas