Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cycle9 msbuild bug 49097 Patch #1 #1369

Merged
merged 2 commits into from
Dec 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,24 @@ PDictionary MergeEntitlementDictionary (PDictionary dict, MobileProvision profil
return result;
}

static bool AreEqual (byte[] x, byte[] y)
{
if (x.Length != y.Length)
return false;

for (int i = 0; i < x.Length; i++) {
if (x[i] != y[i])
return false;
}

return true;
}

static void WriteXcent (PObject doc, string path)
{
var buf = doc.ToByteArray (false);

using (var stream = File.Open (path, FileMode.Create)) {
using (var stream = new MemoryStream ()) {
if (AppleSdkSettings.XcodeVersion < new Version (4, 4, 1)) {
// write the xcent file with the magic header, length, and the plist
var length = Mono.DataConverter.BigEndian.GetBytes ((uint) buf.Length + 8); // 8 = magic.length + magicLen.Length
Expand All @@ -181,6 +194,21 @@ static void WriteXcent (PObject doc, string path)
}

stream.Write (buf, 0, buf.Length);

var src = stream.ToArray ();
bool save;

// Note: if the destination file already exists, only re-write it if the content will change
if (File.Exists (path)) {
var dest = File.ReadAllBytes (path);

save = !AreEqual (src, dest);
} else {
save = true;
}

if (save)
File.WriteAllBytes (path, src);
}
}

Expand Down Expand Up @@ -285,6 +313,7 @@ public override bool Execute ()
PDictionary compiled;
PDictionary archived;
string path;
bool save;

if (!string.IsNullOrEmpty (ProvisioningProfile)) {
if ((profile = MobileProvisionIndex.GetMobileProvision (Platform, ProvisioningProfile)) == null) {
Expand Down Expand Up @@ -327,11 +356,25 @@ public override bool Execute ()
return false;
}

try {
archived.Save (Path.Combine (EntitlementBundlePath, "archived-expanded-entitlements.xcent"), true);
} catch (Exception ex) {
Log.LogError ("Error writing archived-expanded-entitlements.xcent file: {0}", ex.Message);
return false;
path = Path.Combine (EntitlementBundlePath, "archived-expanded-entitlements.xcent");

if (File.Exists (path)) {
var plist = PDictionary.FromFile (path);
var src = archived.ToXml ();
var dest = plist.ToXml ();

save = src != dest;
} else {
save = true;
}

if (save) {
try {
archived.Save (path, true);
} catch (Exception ex) {
Log.LogError ("Error writing archived-expanded-entitlements.xcent file: {0}", ex.Message);
return false;
}
}

return !Log.HasLoggedErrors;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.IO;
using System.IO;
using System.Linq;

using Microsoft.Build.Framework;
Expand Down Expand Up @@ -39,6 +38,13 @@ public override bool Execute ()

var embedded = Path.Combine (AppBundleDir, "embedded.mobileprovision");

if (File.Exists (embedded)) {
var embeddedProfile = MobileProvision.LoadFromFile (embedded);

if (embeddedProfile.Uuid == profile.Uuid)
return true;
}

Directory.CreateDirectory (AppBundleDir);
profile.Save (embedded);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,6 @@ void OptimizePngs_Core (bool shouldBeDifferent)
}

[Test]
[Ignore ("This test fails due to bugs in our implementation")]
public void RebuildExecutable_NoModifications ()
{
// Put a thread.sleep so that the initial build happens a noticable amount of time after we copy
Expand All @@ -272,11 +271,11 @@ public void RebuildExecutable_NoModifications ()
// execution of the test fixture 'setup' method.
Thread.Sleep (1000);
RunTarget (MonoTouchProject, TargetName.Build);
var timestamps = ExpectedExecutableFiles.ToDictionary (file => file, file => GetLastModified (file));
var timestamps = Directory.EnumerateFiles (AppBundlePath, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file));

Thread.Sleep (1000);
RunTarget (MonoTouchProject, TargetName.Build);
var newTimestamps = ExpectedExecutableFiles.ToDictionary (file => file, file => GetLastModified (file));
var newTimestamps = Directory.EnumerateFiles (AppBundlePath, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file));

foreach (var file in timestamps.Keys)
Assert.AreEqual (timestamps [file], newTimestamps [file], "#1: " + file);
Expand Down