Skip to content

Commit

Permalink
[msbuild] Port the tasks and tests to use new msbuild API
Browse files Browse the repository at this point in the history
Mono's msbuild does not have implementation assemblies for the older
APIs (think `Microsoft.Build.Engine`), and so as part of the port to
msbuild we switch over to using the newer APIs.

With this commit, we are buildable again (with lots of test failures!).
  • Loading branch information
radical committed May 22, 2018
1 parent 256035e commit a5670f2
Show file tree
Hide file tree
Showing 10 changed files with 202 additions and 149 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void BuildTest ()
AppBundlePath = mtouchPaths.AppBundlePath;
var dllPath = Path.Combine(mtouchPaths.ProjectBinPath, "bindings-test.dll");

Engine.GlobalProperties.SetProperty ("Platform", Platform);
Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform);

RunTarget (proj, "Build", 0);
Assert.IsTrue (File.Exists (dllPath), "{1} binding dll does not exist: {0} ", dllPath, Platform);
Expand All @@ -43,7 +43,7 @@ public void FrameworkTest ()
AppBundlePath = mtouchPaths.AppBundlePath;
var dllPath = Path.Combine(mtouchPaths.ProjectBinPath, "bindings-test.dll");

Engine.GlobalProperties.SetProperty ("Platform", Platform);
Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform);

RunTarget (proj, "Build", 0);
Assert.IsTrue (File.Exists (dllPath), "{1} binding dll does not exist: {0} ", dllPath, Platform);
Expand Down
11 changes: 6 additions & 5 deletions msbuild/tests/Xamarin.iOS.Tasks.Tests/ProjectsTests/Bug60536.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
using System.Linq;
using System.Collections;

using NUnit.Framework;
using Microsoft.Build.Evaluation;

using Microsoft.Build.BuildEngine;
using NUnit.Framework;

namespace Xamarin.iOS.Tasks
{
Expand All @@ -30,8 +30,8 @@ public void TestACToolTaskCatchesJsonException ()
var project = SetupProject (Engine, csproj);

AppBundlePath = mtouchPaths ["app_bundlepath"];
Engine.GlobalProperties.SetProperty("Platform", platform);
Engine.GlobalProperties.SetProperty("Configuration", config);
Engine.ProjectCollection.SetGlobalProperty("Platform", platform);
Engine.ProjectCollection.SetGlobalProperty("Configuration", config);

if (clean) {
RunTarget (project, "Clean");
Expand All @@ -56,8 +56,9 @@ public void TestACToolTaskCatchesJsonException ()
}

project = SetupProject (Engine, mtouchPaths.ProjectCSProjPath);
var projectInstance = project.CreateProjectInstance ();

Engine.BuildProject (project, new [] { target }, new Hashtable { {"Platform", "iPhone"} }, BuildSettings.None);
Engine.BuildProject (projectInstance, new [] { target }, new Hashtable { {"Platform", "iPhone"} });
if (Engine.Logger.ErrorEvents.Count != 1) {
string messages = string.Empty;
if (Engine.Logger.ErrorEvents.Count > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public void BuildExtension (string hostAppName, string extensionName, string bun

AppBundlePath = mtouchPaths ["app_bundlepath"];
string extensionPath = Path.Combine(AppBundlePath, "PlugIns", extensionName + ".appex");
Engine.GlobalProperties.SetProperty ("Platform", platform);
Engine.GlobalProperties.SetProperty ("Configuration", config);
Engine.ProjectCollection.SetGlobalProperty ("Platform", platform);
Engine.ProjectCollection.SetGlobalProperty ("Configuration", config);

RunTarget (proj, "Clean");
Assert.IsFalse (Directory.Exists (AppBundlePath), "{1}: App bundle exists after cleanup: {0} ", AppBundlePath, bundlePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public void InvalidBundleIdTest ()
File.WriteAllText (appInfoPath, appInfoContents.Replace ("<string>com.xamarin.MyWatchApp</string>", "<string>com.xamarin.MyWatchAppX</string>"));

var proj = SetupProject (Engine, mtouchPaths.ProjectCSProjPath);
Engine.GlobalProperties.SetProperty ("Platform", Platform);
Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform);
AppBundlePath = mtouchPaths ["app_bundlepath"];
RunTarget (proj, "Build", 2);
Assert.AreEqual ("The App Extension 'WatchExtension' has an invalid CFBundleIdentifier (com.xamarin.MyWatchApp.WatchExtension), it does not begin with the main app bundle's CFBundleIdentifier (com.xamarin.MyWatchAppX).", Engine.Logger.ErrorEvents [0].Message, "#1");
Expand All @@ -61,12 +61,12 @@ public void CreateIpa ()

AppBundlePath = mtouchPaths.AppBundlePath;

Engine.GlobalProperties.SetProperty ("Platform", Platform);
Engine.GlobalProperties.SetProperty ("BuildIpa", "true");
Engine.GlobalProperties.SetProperty ("IpaIncludeArtwork", "true");
Engine.GlobalProperties.SetProperty ("CodesignProvision", "Automatic"); // Provisioning profile
Engine.GlobalProperties.SetProperty ("CodesignKey", "iPhone Developer");
Engine.GlobalProperties.SetProperty ("Configuration", configuration);
Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform);
Engine.ProjectCollection.SetGlobalProperty ("BuildIpa", "true");
Engine.ProjectCollection.SetGlobalProperty ("IpaIncludeArtwork", "true");
Engine.ProjectCollection.SetGlobalProperty ("CodesignProvision", "Automatic"); // Provisioning profile
Engine.ProjectCollection.SetGlobalProperty ("CodesignKey", "iPhone Developer");
Engine.ProjectCollection.SetGlobalProperty ("Configuration", configuration);

RunTarget (proj, "Clean");
Assert.IsFalse (Directory.Exists (AppBundlePath), "{1}: App bundle exists after cleanup: {0} ", AppBundlePath, Platform);
Expand Down Expand Up @@ -103,7 +103,7 @@ public void CreateIpa ()
string wkPath = "WatchKitSupport/WK";
Assert.Contains (wkPath, lines, wkPath + " does not exist");

var ipaIncludeArtwork = proj.GetEvaluatedProperty ("IpaIncludeArtwork");
var ipaIncludeArtwork = proj.GetPropertyValue ("IpaIncludeArtwork");
Assert.IsTrue (output.Contains ("iTunesMetadata.plist"), string.Format ("The ipa should contain at least one iTunesMetadata.plist file if we are using an AppStore config and IpaIncludeArtwork is true. IpaIncludeArtwork: {0}", ipaIncludeArtwork));

RunTarget (proj, "Clean");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using NUnit.Framework;

namespace Xamarin.iOS.Tasks {
Expand All @@ -16,12 +17,12 @@ public void BasicTest ()
{
var mtouchPaths = SetupProjectPaths ("MyTabbedApplication", "../", true, Platform);

Engine.GlobalProperties.SetProperty ("Platform", Platform);
Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform);

var proj = SetupProject (Engine, mtouchPaths.ProjectCSProjPath);
var nr = proj.AddNewItem ("NativeReference", Path.Combine (".", "..", "..", "..", "tests", "test-libraries", ".libs", "ios", "XTest.framework"));
nr.SetMetadata ("IsCxx", "False");
nr.SetMetadata ("Kind", "Framework");
var nr = proj.AddItem ("NativeReference", Path.Combine (".", "..", "..", "..", "tests", "test-libraries", ".libs", "ios", "XTest.framework")).First ();
nr.SetMetadataValue ("IsCxx", "False");
nr.SetMetadataValue ("Kind", "Framework");

AppBundlePath = mtouchPaths.AppBundlePath;

Expand All @@ -40,14 +41,14 @@ public void WithIncrementalBuilds ()

var mtouchPaths = SetupProjectPaths ("MyiOSAppWithBinding", "../", true, Platform);

Engine.GlobalProperties.SetProperty ("Platform", Platform);
Engine.ProjectCollection.SetGlobalProperty ("Platform", Platform);

var proj = SetupProject (Engine, mtouchPaths.ProjectCSProjPath);

proj.GlobalProperties.SetProperty ("MtouchFastDev", "true");
proj.GlobalProperties.SetProperty ("MtouchExtraArgs", "-vvvv");
proj.GlobalProperties.SetProperty ("MtouchArch", "ARM64"); // only use ARM64 to speed up the build.
proj.GlobalProperties.SetProperty ("MtouchLink", "Full"); // also to speed up the build.
proj.SetGlobalProperty ("MtouchFastDev", "true");
proj.SetGlobalProperty ("MtouchExtraArgs", "-vvvv");
proj.SetGlobalProperty ("MtouchArch", "ARM64"); // only use ARM64 to speed up the build.
proj.SetGlobalProperty ("MtouchLink", "Full"); // also to speed up the build.

AppBundlePath = mtouchPaths.AppBundlePath;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ public string BuildProject (string appName, string platform, string config, int
var proj = SetupProject (Engine, csproj);

AppBundlePath = mtouchPaths ["app_bundlepath"];
Engine.GlobalProperties.SetProperty("Platform", platform);
Engine.GlobalProperties.SetProperty("Configuration", config);
Engine.ProjectCollection.SetGlobalProperty("Platform", platform);
Engine.ProjectCollection.SetGlobalProperty("Configuration", config);

if (clean) {
RunTarget (proj, "Clean");
Expand Down
Loading

0 comments on commit a5670f2

Please sign in to comment.