diff --git a/src/Squirrel/ContentType.cs b/src/Squirrel/ContentType.cs
index 97fa2c451..61c65d57d 100644
--- a/src/Squirrel/ContentType.cs
+++ b/src/Squirrel/ContentType.cs
@@ -10,6 +10,7 @@ public static void Merge(XmlDocument doc)
{
var elements = new [] {
Tuple.Create("Default", "diff", "application/octet" ),
+ Tuple.Create("Default", "bsdiff", "application/octet" ),
Tuple.Create("Default", "exe", "application/octet" ),
Tuple.Create("Default", "dll", "application/octet" ),
Tuple.Create("Default", "shasum", "text/plain" ),
diff --git a/src/Squirrel/DeltaPackage.cs b/src/Squirrel/DeltaPackage.cs
index 250f115e7..66aad3e74 100644
--- a/src/Squirrel/DeltaPackage.cs
+++ b/src/Squirrel/DeltaPackage.cs
@@ -9,6 +9,7 @@
using Splat;
using DeltaCompressionDotNet.MsDelta;
using System.ComponentModel;
+using Squirrel.Bsdiff;
namespace Squirrel
{
@@ -176,9 +177,25 @@ void createDeltaForSingleFile(FileInfo targetFile, DirectoryInfo workingDirector
var msDelta = new MsDeltaCompression();
try {
msDelta.CreateDelta(baseFileListing[relativePath], targetFile.FullName, targetFile.FullName + ".diff");
- } catch (Win32Exception ex) {
- this.Log().Warn("We couldn't create a delta for {0}, writing full file", targetFile.Name);
- return;
+ } catch (Win32Exception) {
+ this.Log().Warn("We couldn't create a delta for {0}, attempting to create bsdiff", targetFile.Name);
+
+ var of = default(FileStream);
+ try {
+ of = File.Create(targetFile.FullName + ".bsdiff");
+ BinaryPatchUtility.Create(oldData, newData, of);
+
+ // NB: Create a dummy corrupt .diff file so that older
+ // versions which don't understand bsdiff will fail out
+ // until they get upgraded, instead of seeing the missing
+ // file and just removing it.
+ File.WriteAllText(targetFile.FullName + ".diff", "1");
+ } catch (Exception ex) {
+ this.Log().WarnException(String.Format("We really couldn't create a delta for {0}", targetFile.Name), ex);
+ return;
+ } finally {
+ if (of != null) of.Dispose();
+ }
}
var rl = ReleaseEntry.GenerateFromFile(new MemoryStream(newData), targetFile.Name + ".shasum");
@@ -202,13 +219,20 @@ void applyDiffToFile(string deltaPath, string relativeFilePath, string workingDi
return;
}
- if (relativeFilePath.EndsWith(".diff", StringComparison.InvariantCultureIgnoreCase)) {
- this.Log().Info("Applying Diff to {0}", relativeFilePath);
+ if (relativeFilePath.EndsWith(".bsdiff", StringComparison.InvariantCultureIgnoreCase)) {
+ using (var of = File.OpenWrite(tempTargetFile))
+ using (var inf = File.OpenRead(finalTarget)) {
+ this.Log().Info("Applying BSDiff to {0}", relativeFilePath);
+ BinaryPatchUtility.Apply(inf, () => File.OpenRead(inputFile), of);
+ }
+
+ verifyPatchedFile(relativeFilePath, inputFile, tempTargetFile);
+ } else if (relativeFilePath.EndsWith(".diff", StringComparison.InvariantCultureIgnoreCase)) {
+ this.Log().Info("Applying MSDiff to {0}", relativeFilePath);
var msDelta = new MsDeltaCompression();
msDelta.ApplyDelta(inputFile, finalTarget, tempTargetFile);
verifyPatchedFile(relativeFilePath, inputFile, tempTargetFile);
-
} else {
using (var of = File.OpenWrite(tempTargetFile))
using (var inf = File.OpenRead(inputFile)) {
diff --git a/src/Squirrel/ReleasePackage.cs b/src/Squirrel/ReleasePackage.cs
index 87d898663..cda5c30e4 100644
--- a/src/Squirrel/ReleasePackage.cs
+++ b/src/Squirrel/ReleasePackage.cs
@@ -101,7 +101,6 @@ public string CreateReleasePackage(string outputFile, string packagesRootDir = n
// ever expect one entry here (crash hard otherwise)
var frameworks = package.GetSupportedFrameworks();
if (frameworks.Count() > 1) {
-
var platforms = frameworks
.Aggregate(new StringBuilder(), (sb, f) => sb.Append(f.ToString() + "; "));
@@ -109,7 +108,6 @@ public string CreateReleasePackage(string outputFile, string packagesRootDir = n
"The input package file {0} targets multiple platforms - {1} - and cannot be transformed into a release package.", InputPackageFile, platforms));
} else if (!frameworks.Any()) {
-
throw new InvalidOperationException(String.Format(
"The input package file {0} targets no platform and cannot be transformed into a release package.", InputPackageFile));
}
diff --git a/src/Squirrel/Squirrel.csproj b/src/Squirrel/Squirrel.csproj
index 3e21d5585..fc441c529 100644
--- a/src/Squirrel/Squirrel.csproj
+++ b/src/Squirrel/Squirrel.csproj
@@ -87,6 +87,7 @@
Properties\SolutionAssemblyInfo.cs
+