Today my Windows Phone 7 solution started giving me one single build error:
Xap packaging failed. Object reference not set to an instance of an object.
A file had been removed from disk but not from the solution. Always set your sample data files to Build action: None.
After a few rounds of clean, rebuild, machine reboot etc., I started thinking and remembered that I had replaced an image in my Expression Blend sample data and removed the old one. Looking at the solution explorer confirms this, on file missing. Excluding this file from the solution removed the problem, I can now build again. But, why would the XAP packager fail on a file only used by the sample data?
So, the XAP packaging failed due to a missing image file, something must be wrong. Normal build action for images used by the application should be either content or resource, see WindowsPhoneGeek – Working with images… for more info on this. But, an image what will only be used by Blend to show sample data should not be included in the build and therefore have build action: none. Changing my banner.png to Build action: None made the build go through. Of course the missing file should be excluded, but at least now we can build.
Bye for now!