Visual Studio packs into WP8 XAP unnecessary XML doc files
Asked Answered
D

1

8

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.

Dosimeter answered 13/2, 2013 at 8:33 Comment(4)
Can you specify with what NuGet packages does this happen?Apteryx
Reactive Extensions - Main Lib, for example.Dosimeter
Seeing it too, think it has something to do with the differences between the MSBuild scripts for WP7 and WP8, I'll try to dig this better once I have the chance!Apteryx
Read comments to your code from System.Reactive.Core.xml?Reeva
A
6

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!

Apteryx answered 14/2, 2013 at 13:56 Comment(7)
Thanks for the reply. I've tested your solution and found that XML doc files are removed from the output dir but still get packed into XAP :(Dosimeter
Right now the above solution seems to be working fine both in WP8 and Win8 apps, can you provide a sample project of yours for me to test? Are you using Visual Studio Express?Apteryx
Please ensure that you actually do a clean + build (or rebuild) of the solution! If nothing else works, fell free to contact me directly (contacts in my profile)Apteryx
I tried the same things by adding Bing map SDK in Win8 app, there's nothing change in the size of APPX. Can you please test this ?Lizzettelizzie
@Pedro After investigating the problem more deeply, i find that one should modify each WP8 project file in the VS solution (not just main one) - this helped me. Thank you very much for the work done!Dosimeter
Happy to see the solution. I think that this is a actual problem that every WP8/W8 app developer must know. Probably every WP8/W8 app in the store is already large in size than it must be.Oligochaete
After reading your comments, I rechecked and confirmed that you did have to add that to ALL projects... I've edited my answer with a new solution that only requires to be added to the main project.Apteryx

© 2022 - 2024 — McMap. All rights reserved.