Skip to content

Commit

Permalink
[msbuild] Make the CompileAppManifestTaskBase.AppManifest property an…
Browse files Browse the repository at this point in the history
… ITaskItem. (#12804)

So that any input app manifest is copied to Windows when doing remote builds.
  • Loading branch information
rolfbjarne authored Sep 23, 2021
1 parent fb2d6fc commit 5318a2b
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ public abstract class CompileAppManifestTaskBase : XamarinTask
[Required]
public string AppBundleName { get; set; }

public string AppManifest { get; set; }
// This must be an ITaskItem to copy the file to Windows for remote builds.
public ITaskItem AppManifest { get; set; }

[Required]
public string AssemblyName { get; set; }
Expand Down Expand Up @@ -93,11 +94,12 @@ public override bool Execute ()
{
PDictionary plist = null;

if (File.Exists (AppManifest)) {
var appManifest = AppManifest?.ItemSpec;
if (File.Exists (appManifest)) {
try {
plist = PDictionary.FromFile (AppManifest);
plist = PDictionary.FromFile (appManifest);
} catch (Exception ex) {
LogAppManifestError (MSBStrings.E0010, AppManifest, ex.Message);
LogAppManifestError (MSBStrings.E0010, appManifest, ex.Message);
return false;
}
} else {
Expand Down Expand Up @@ -238,11 +240,11 @@ bool SetMinimumOSVersion (PDictionary plist)
minimumOSVersion = SdkVersion;
}
} else if (!IAppleSdkVersion_Extensions.TryParse (minimumOSVersionInManifest, out var _)) {
Log.LogError (null, null, null, AppManifest, 0, 0, 0, 0, MSBStrings.E0011, minimumOSVersionInManifest);
LogAppManifestError (MSBStrings.E0011, minimumOSVersionInManifest);
return false;
} else if (!string.IsNullOrEmpty (convertedSupportedOSPlatformVersion) && convertedSupportedOSPlatformVersion != minimumOSVersionInManifest) {
// SupportedOSPlatformVersion and the value in the Info.plist are not the same. This is an error.
Log.LogError (null, null, null, AppManifest, 0, 0, 0, 0, MSBStrings.E7082, minimumVersionKey, minimumOSVersionInManifest, SupportedOSPlatformVersion);
LogAppManifestError (MSBStrings.E7082, minimumVersionKey, minimumOSVersionInManifest, SupportedOSPlatformVersion);
return false;
} else {
minimumOSVersion = minimumOSVersionInManifest;
Expand All @@ -259,13 +261,22 @@ bool SetMinimumOSVersion (PDictionary plist)
protected void LogAppManifestError (string format, params object[] args)
{
// Log an error linking to the Info.plist file
Log.LogError (null, null, null, AppManifest, 0, 0, 0, 0, format, args);
if (AppManifest != null) {
Log.LogError (null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, format, args);
} else {
Log.LogError (format, args);
}

}

protected void LogAppManifestWarning (string format, params object[] args)
{
// Log a warning linking to the Info.plist file
Log.LogWarning (null, null, null, AppManifest, 0, 0, 0, 0, format, args);
if (AppManifest != null) {
Log.LogWarning (null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, format, args);
} else {
Log.LogWarning (format, args);
}
}

protected void SetValue (PDictionary dict, string key, string value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public void MainMinimumOSVersions ()
main.SetMinimumOSVersion ("14.0");
main.Save (mainPath);

task.AppManifest = mainPath;
task.AppManifest = new TaskItem (mainPath);

ExecuteTask (task);

Expand All @@ -77,7 +77,7 @@ public void MultipleMinimumOSVersions ()
partial.SetMinimumOSVersion ("13.0");
partial.Save (partialPath);

task.AppManifest = mainPath;
task.AppManifest = new TaskItem (mainPath);
task.PartialAppManifests = new [] { new TaskItem (partialPath) };

ExecuteTask (task);
Expand All @@ -96,7 +96,7 @@ public void ErrorWithMismatchedInfoPlistMinimumOSVersion ()
plist.SetMinimumOSVersion ("10.0");
var manifest = Path.Combine (dir, "Info.plist");
plist.Save (manifest);
task.AppManifest = manifest;
task.AppManifest = new TaskItem (manifest);
task.SupportedOSPlatformVersion = "11.0";

ExecuteTask (task, expectedErrorCount: 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ public virtual void ConfigureTask ()
Task.AppBundleName = appBundleName;
Task.CompiledAppManifest = new TaskItem (Path.Combine (Cache.CreateTemporaryDirectory (), "AppBundlePath", "Info.plist"));
Task.AssemblyName = assemblyName;
Task.AppManifest = CreateTempFile ("foo.plist");
Task.AppManifest = new TaskItem (CreateTempFile ("foo.plist"));
Task.SdkPlatform = "iPhoneSimulator";
Task.SdkVersion = "10.0";

Plist = new PDictionary ();
Plist ["CFBundleDisplayName"] = displayName;
Plist ["CFBundleIdentifier"] = bundleIdentifier;
Plist.Save (Task.AppManifest);
Plist.Save (Task.AppManifest.ItemSpec);
}

public override void Setup ()
Expand All @@ -62,7 +62,7 @@ public override void Setup ()
[Test]
public void PlistMissing ()
{
File.Delete (Task.AppManifest);
File.Delete (Task.AppManifest.ItemSpec);
Assert.IsTrue (Task.Execute (), "#1");
Assert.That (Task.CompiledAppManifest.ItemSpec, Does.Exist, "#2");
}
Expand All @@ -79,15 +79,15 @@ public void NormalPlist ()
public void MissingBundleIdentifier ()
{
Plist.Remove ("CFBundleIdentifier");
Plist.Save (Task.AppManifest);
Plist.Save (Task.AppManifest.ItemSpec);
Assert.IsTrue (Task.Execute (), "#1");
}

[Test]
public void MissingDisplayName ()
{
Plist.Remove ("CFBundleDisplayName");
Plist.Save (Task.AppManifest);
Plist.Save (Task.AppManifest.ItemSpec);
Assert.IsTrue (Task.Execute (), "#1");
}

Expand Down

3 comments on commit 5318a2b

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❌ [CI Build] Tests failed on Build ❌

Tests failed on Build.

API diff

✅ API Diff from stable

View API diff

API & Generator diff

API Diff (from PR only) (no change)
Generator Diff (only version changes)

Packages generated

View packages

Test results

2 tests failed, 241 tests passed.

Failed tests

  • dont link/Mac Catalyst [dotnet]/Release [dotnet]: Failed (Test run crashed (exit code: 134).
    Tests run: 11 Passed: 6 Inconclusive: 0 Failed: 0 Ignored: 5)
  • Documentation/All: Failed

Pipeline on Agent XAMBOT-1036.BigSur'
[msbuild] Make the CompileAppManifestTaskBase.AppManifest property an ITaskItem. (#12804)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Tests were not ran (VSTS: device tests tvOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[msbuild] Make the CompileAppManifestTaskBase.AppManifest property an ITaskItem. (#12804)

@vs-mobiletools-engineering-service2
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Tests were not ran (VSTS: device tests iOS). ⚠️

Results were skipped for this run due to provisioning problems Azure Devops. Please contact the bot administrator.

Pipeline on Agent
[msbuild] Make the CompileAppManifestTaskBase.AppManifest property an ITaskItem. (#12804)

Please sign in to comment.