Cross-cutting Tip #7
The round trip is not a no-op
Unpack a package and pack it back and you do not get the file you started with: the XML gains a declaration, the line endings change, and the empty containers come back collapsed.
Diff a package against the one you packed it from, and you will find changes nobody made. The round
trip through unpack and pack rewrites both XML files, and every difference is in the wrapper rather
than the solution.
The solution.xml inside Microsoft’s own package opens like this:
<ImportExportXml version="9.2.26083.148" SolutionPackageVersion="9.2" ...
Pack the folder it unpacked to, and the same file opens with an XML declaration the original did not carry:
<?xml version="1.0" encoding="utf-8"?>
customizations.xml is the one that moves more. The original carries <Roles>, <Workflows> and
<FieldSecurityProfiles> as open tags with nothing inside them, and all three come back collapsed to
<Roles />, <Workflows /> and <FieldSecurityProfiles />. The line endings change as well - the member
inside the package is CRLF and the file you pack back is LF - which on its own is a whole-file diff, before
you have changed anything. In
Microsoft’s sample neither a role, a workflow, nor a field security profile is anywhere in the package.
You did not make any of those changes - the writer puts back the elements the reader elides. A diff between “the package I imported last week” and “the package I built today” is not a diff of the solution: the first line of the file differs even when you changed nothing.
The version attribute is worth reading before you lean on it, too. 9.2.26083.148 in the line above is
the platform build that wrote the file you started from, and it is not a number your build produces.
If you want to know what changed between two solutions, compare unpacked folders - components, not containers. The XML that wraps them is rewritten every time someone touches it.