From 2f064b57782c33c1a4b097a702b1d588160f81d7 Mon Sep 17 00:00:00 2001 From: joj Date: Wed, 25 May 2016 10:34:44 -0300 Subject: [PATCH] Added support for Windows builds of Xamarin.Mac --- .../MacOSXSdks.cs | 0 .../Properties/AssemblyInfo.cs | 36 +++ .../Tasks/DetectSdkLocations.cs | 145 +++++++++++ .../Tasks/EmbedProvisionProfile.cs | 59 +++++ msbuild/Xamarin.Mac.Tasks.Core/Tasks/Mmp.cs | 229 ++++++++++++++++++ .../Tasks/XamMacArch.cs | 0 .../Xamarin.Mac.Tasks.Core.csproj | 55 +++++ .../Tasks/DetectSdkLocations.cs | 128 +--------- .../Tasks/EmbedProvisionProfile.cs | 42 +--- msbuild/Xamarin.Mac.Tasks/Tasks/Mmp.cs | 206 +--------------- .../Xamarin.Mac.Common.targets | 73 ++++-- .../Xamarin.Mac.Tasks.csproj | 14 +- msbuild/Xamarin.MacDev.Tasks.sln | 60 +++-- 13 files changed, 618 insertions(+), 429 deletions(-) rename msbuild/{Xamarin.Mac.Tasks => Xamarin.Mac.Tasks.Core}/MacOSXSdks.cs (100%) create mode 100644 msbuild/Xamarin.Mac.Tasks.Core/Properties/AssemblyInfo.cs create mode 100644 msbuild/Xamarin.Mac.Tasks.Core/Tasks/DetectSdkLocations.cs create mode 100644 msbuild/Xamarin.Mac.Tasks.Core/Tasks/EmbedProvisionProfile.cs create mode 100644 msbuild/Xamarin.Mac.Tasks.Core/Tasks/Mmp.cs rename msbuild/{Xamarin.Mac.Tasks => Xamarin.Mac.Tasks.Core}/Tasks/XamMacArch.cs (100%) create mode 100644 msbuild/Xamarin.Mac.Tasks.Core/Xamarin.Mac.Tasks.Core.csproj diff --git a/msbuild/Xamarin.Mac.Tasks/MacOSXSdks.cs b/msbuild/Xamarin.Mac.Tasks.Core/MacOSXSdks.cs similarity index 100% rename from msbuild/Xamarin.Mac.Tasks/MacOSXSdks.cs rename to msbuild/Xamarin.Mac.Tasks.Core/MacOSXSdks.cs diff --git a/msbuild/Xamarin.Mac.Tasks.Core/Properties/AssemblyInfo.cs b/msbuild/Xamarin.Mac.Tasks.Core/Properties/AssemblyInfo.cs new file mode 100644 index 000000000000..22e06522a409 --- /dev/null +++ b/msbuild/Xamarin.Mac.Tasks.Core/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Xamarin.Mac.Tasks.Core")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Xamarin.Mac.Tasks.Core")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("af1ac7c3-f6dd-4e46-b897-9dbb90b158ec")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/msbuild/Xamarin.Mac.Tasks.Core/Tasks/DetectSdkLocations.cs b/msbuild/Xamarin.Mac.Tasks.Core/Tasks/DetectSdkLocations.cs new file mode 100644 index 000000000000..dba3c449f3c4 --- /dev/null +++ b/msbuild/Xamarin.Mac.Tasks.Core/Tasks/DetectSdkLocations.cs @@ -0,0 +1,145 @@ +using System; +using System.IO; +using System.Linq; + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +using Xamarin.MacDev.Tasks; +using Xamarin.MacDev; + +namespace Xamarin.Mac.Tasks +{ + public class DetectSdkLocationsTaskBase : Task + { + #region Inputs + + public string SessionId { get; set; } + + // This is also an input + [Output] + public string SdkVersion { + get; set; + } + + public string XamarinSdkRoot { + get; set; + } + + #endregion Inputs + + #region Outputs + + [Output] + public string SdkRoot { + get; set; + } + + [Output] + public string SdkBinPath { + get; set; + } + + [Output] + public string SdkDevPath { + get; set; + } + + [Output] + public string SdkUsrPath { + get; set; + } + + #endregion Outputs + + public override bool Execute () + { + Log.LogTaskName ("DetectSdkLocations"); + Log.LogTaskProperty ("SdkVersion", SdkVersion); + Log.LogTaskProperty ("XamarinSdkRoot", XamarinSdkRoot); + + EnsureAppleSdkRoot (); + EnsureXamarinSdkRoot (); + EnsureSdkPath (); + + return !Log.HasLoggedErrors; + } + + void EnsureSdkPath () + { + MacOSXSdkVersion requestedSdkVersion; + if (string.IsNullOrEmpty (SdkVersion)) { + requestedSdkVersion = MacOSXSdkVersion.UseDefault; + } else if (!MacOSXSdkVersion.TryParse (SdkVersion, out requestedSdkVersion)) { + Log.LogError ("Could not parse the SDK version '{0}'", SdkVersion); + return; + } + + var sdkVersion = requestedSdkVersion.ResolveIfDefault (MacOSXSdks.Native); + if (!MacOSXSdks.Native.SdkIsInstalled (sdkVersion)) { + sdkVersion = MacOSXSdks.Native.GetClosestInstalledSdk (sdkVersion); + + if (sdkVersion.IsUseDefault || !MacOSXSdks.Native.SdkIsInstalled (sdkVersion)) { + if (requestedSdkVersion.IsUseDefault) { + Log.LogError ("The Apple MacOSX SDK is not installed."); + } else { + Log.LogError ("The MacOSX SDK version '{0}' is not installed, and no newer version was found.", requestedSdkVersion.ToString ()); + } + return; + } + Log.LogWarning ("The MacOSX SDK version '{0}' is not installed. Using newer version '{1}' instead'.", requestedSdkVersion, sdkVersion); + } + + SdkVersion = sdkVersion.ToString (); + + SdkRoot = MacOSXSdks.Native.GetSdkPath (sdkVersion); + if (string.IsNullOrEmpty (SdkRoot)) + Log.LogError ("Could not locate the MacOSX '{0}' SDK at path '{1}'", SdkVersion, SdkRoot); + + SdkUsrPath = DirExists ("SDK usr directory", Path.Combine (MacOSXSdks.Native.DeveloperRoot, "usr")); + if (string.IsNullOrEmpty (SdkUsrPath)) + Log.LogError ("Could not locate the MacOSX '{0}' SDK usr path at '{1}'", SdkVersion, SdkRoot); + + SdkBinPath = DirExists ("SDK bin directory", Path.Combine (SdkUsrPath, "bin")); + if (string.IsNullOrEmpty (SdkBinPath)) + Log.LogError ("Could not locate SDK bin directory"); + } + + void EnsureAppleSdkRoot () + { + if (!MacOSXSdks.Native.IsInstalled) { + Log.LogError (" Could not find valid a usable Xcode app bundle"); + } else { + Log.LogMessage (MessageImportance.Low, " DeveloperRoot: {0}", MacOSXSdks.Native.DeveloperRoot); + Log.LogMessage (MessageImportance.Low, " GetPlatformPath: {0}", MacOSXSdks.Native.GetPlatformPath ()); + + SdkDevPath = MacOSXSdks.Native.DeveloperRoot; + if (string.IsNullOrEmpty (SdkDevPath)) + Log.LogError (" Could not find valid a usable Xcode developer path"); + } + } + + void EnsureXamarinSdkRoot () + { + if (string.IsNullOrEmpty (XamarinSdkRoot)) + XamarinSdkRoot = MacOSXSdks.XamMac.FrameworkDirectory; + + if (string.IsNullOrEmpty (XamarinSdkRoot) || !Directory.Exists (XamarinSdkRoot)) + Log.LogError (" Could not find 'Xamarin.Mac'"); + } + + string DirExists (string checkingFor, params string[] paths) + { + try { + if (paths.Any (p => string.IsNullOrEmpty (p))) + return null; + + var path = Path.GetFullPath (Path.Combine (paths)); + Log.LogMessage (MessageImportance.Low, " Searching for '{0}' in '{1}'", checkingFor, path); + return Directory.Exists (path) ? path : null; + } catch { + return null; + } + } + } +} diff --git a/msbuild/Xamarin.Mac.Tasks.Core/Tasks/EmbedProvisionProfile.cs b/msbuild/Xamarin.Mac.Tasks.Core/Tasks/EmbedProvisionProfile.cs new file mode 100644 index 000000000000..a345b9fe1922 --- /dev/null +++ b/msbuild/Xamarin.Mac.Tasks.Core/Tasks/EmbedProvisionProfile.cs @@ -0,0 +1,59 @@ +using System; +using System.IO; +using System.Linq; + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +using Xamarin.MacDev.Tasks; +using Xamarin.MacDev; + +namespace Xamarin.Mac.Tasks +{ + public class EmbedProvisionProfileTaskBase : Task + { + #region Inputs + + public string SessionId { get; set; } + + [Required] + public string AppBundleDir { get; set; } + + [Required] + public string ProvisioningProfile { get; set; } + + #endregion + + static MobileProvision GetMobileProvision (MobileProvisionPlatform platform, string uuid) + { + var extension = MobileProvision.GetFileExtension (platform); + var path = Path.Combine (MobileProvision.ProfileDirectory, uuid + extension); + + if (File.Exists (path)) + return MobileProvision.LoadFromFile (path); + + return MobileProvision.GetAllInstalledProvisions (platform, true).FirstOrDefault (x => x.Uuid == uuid); + } + + public override bool Execute () + { + Log.LogTaskName ("EmbedProvisionProfile"); + Log.LogTaskProperty ("AppBundleDir", AppBundleDir); + Log.LogTaskProperty ("ProvisioningProfile", ProvisioningProfile); + + var profile = GetMobileProvision (MobileProvisionPlatform.MacOS, ProvisioningProfile); + + if (profile == null) { + Log.LogError ("Could not locate the provisioning profile with a UUID of {0}.", ProvisioningProfile); + return false; + } + + var embedded = Path.Combine (AppBundleDir, "Contents", "embedded.provisionprofile"); + + Directory.CreateDirectory (AppBundleDir); + profile.Save (embedded); + + return true; + } + } +} diff --git a/msbuild/Xamarin.Mac.Tasks.Core/Tasks/Mmp.cs b/msbuild/Xamarin.Mac.Tasks.Core/Tasks/Mmp.cs new file mode 100644 index 000000000000..ac491b9c4cde --- /dev/null +++ b/msbuild/Xamarin.Mac.Tasks.Core/Tasks/Mmp.cs @@ -0,0 +1,229 @@ +// +// MmpTask.cs +// +// Author: +// Aaron Bockover +// +// Copyright 2014 Xamarin Inc. + +using System; +using System.IO; + +using Microsoft.Build.Framework; +using Microsoft.Build.Utilities; + +using Xamarin.MacDev.Tasks; +using Xamarin.MacDev; + +namespace Xamarin.Mac.Tasks +{ + public class MmpTaskBase : ToolTask + { + protected override string ToolName { + get { return "mmp"; } + } + + public string SessionId { get; set; } + + [Required] + public string FrameworkRoot { get; set; } + + [Required] + public string OutputPath { get; set; } + + [Required] + public string ApplicationAssembly { get; set; } + + [Required] + public string HttpClientHandler { get; set; } + + [Required] + public string TargetFrameworkIdentifier { get; set; } + + [Required] + public string TargetFrameworkVersion { get; set; } + + [Required] + public string TLSProvider { get; set; } + + [Required] + public string SdkRoot { get; set; } + + [Required] + public ITaskItem AppManifest { get; set; } + + [Required] + public string SdkVersion { get; set; } + + public bool UseXamMacFullFramework { get; set; } + + public string ApplicationName { get; set; } + public string Architecture { get; set; } + public string LinkMode { get; set; } + public bool Debug { get; set; } + public bool Profiling { get; set; } + public string I18n { get; set; } + public string ExtraArguments { get; set; } + + public string [] ExplicitReferences { get; set; } + public string [] NativeReferences { get; set; } + + public string IntermediateOutputPath { get; set; } + + protected override string GenerateFullPathToTool () + { + return Path.Combine (FrameworkRoot, "bin", "mmp"); + } + + protected override bool ValidateParameters () + { + XamMacArch arch; + return Enum.TryParse (Architecture, true, out arch); + } + + protected override string GenerateCommandLineCommands () + { + var args = new ProcessArgumentBuilder (); + + args.Add ("/verbose"); + + if (Debug) + args.Add ("/debug"); + + if (!string.IsNullOrEmpty (OutputPath)) + args.AddQuoted ("/output:" + Path.GetFullPath (OutputPath)); + + if (!string.IsNullOrEmpty (ApplicationName)) + args.AddQuoted ("/name:" + ApplicationName); + + if (TargetFrameworkIdentifier == "Xamarin.Mac") + args.Add ("/profile:Xamarin.Mac"); + else if (TargetFrameworkVersion.StartsWith ("v", StringComparison.Ordinal)) + args.Add ("/profile:" + TargetFrameworkVersion.Substring (1)); + + if (TargetFrameworkIdentifier == "Xamarin.Mac" || UseXamMacFullFramework) { + XamMacArch arch; + if (!Enum.TryParse (Architecture, true, out arch)) + arch = XamMacArch.Default; + + if (arch == XamMacArch.Default) + arch = XamMacArch.x86_64; + + if (arch.HasFlag (XamMacArch.i386)) + args.Add ("/arch:i386"); + + if (arch.HasFlag (XamMacArch.x86_64)) + args.Add ("/arch:x86_64"); + } + else { + args.Add ("/arch:i386"); + } + + args.Add (string.Format ("--http-message-handler={0}", HttpClientHandler)); + + if (AppManifest != null) { + try { + var plist = PDictionary.FromFile (AppManifest.ItemSpec); + + PString v; + string minimumDeploymentTarget; + + if (!plist.TryGetValue (ManifestKeys.LSMinimumSystemVersion, out v) || string.IsNullOrEmpty (v.Value)) + minimumDeploymentTarget = SdkVersion; + else + minimumDeploymentTarget = v.Value; + + args.Add (string.Format("/minos={0}", minimumDeploymentTarget)); + } + catch (Exception ex) { + Log.LogWarning (null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Error loading '{0}': {1}", AppManifest.ItemSpec, ex.Message); + } + } + + if (TargetFrameworkIdentifier == "Xamarin.Mac" && !string.IsNullOrEmpty (TLSProvider)) + args.Add (string.Format ("--tls-provider={0}", TLSProvider.ToLowerInvariant())); + + if (Profiling) + args.Add ("/profiling"); + + switch ((LinkMode ?? String.Empty).ToLower ()) { + case "full": + break; + case "sdkonly": + args.Add ("/linksdkonly"); + break; + default: + args.Add ("/nolink"); + break; + } + + if (!string.IsNullOrEmpty (I18n)) + args.AddQuoted ("/i18n:" + I18n); + + if (ExplicitReferences != null) { + foreach (var asm in ExplicitReferences) + args.AddQuoted ("/assembly:" + Path.GetFullPath (asm)); + } + + if (!string.IsNullOrEmpty (ApplicationAssembly)) + args.AddQuoted (Path.GetFullPath (ApplicationAssembly)); + + if (!string.IsNullOrWhiteSpace (ExtraArguments)) + args.Add (ExtraArguments); + + if (NativeReferences != null) { + foreach (var nr in NativeReferences) + args.AddQuoted ("/native-reference:" + Path.GetFullPath (nr)); + } + + args.Add ("/sdkroot"); + args.AddQuoted (SdkRoot); + + if (!string.IsNullOrEmpty (IntermediateOutputPath)) { + Directory.CreateDirectory (IntermediateOutputPath); + + args.Add ("--cache"); + args.AddQuoted (Path.GetFullPath (IntermediateOutputPath)); + } + + return args.ToString (); + } + + public override bool Execute () + { + Log.LogTaskName ("Mmp"); + Log.LogTaskProperty ("ApplicationAssembly", ApplicationAssembly); + Log.LogTaskProperty ("ApplicationName", ApplicationName); + Log.LogTaskProperty ("Architecture", Architecture); + Log.LogTaskProperty ("Debug", Debug); + Log.LogTaskProperty ("ExplicitReferences", ExplicitReferences); + Log.LogTaskProperty ("ExtraArguments", ExtraArguments); + Log.LogTaskProperty ("FrameworkRoot", FrameworkRoot); + Log.LogTaskProperty ("I18n", I18n); + Log.LogTaskProperty ("IntermediateOutputPath", IntermediateOutputPath); + Log.LogTaskProperty ("LinkMode", LinkMode); + Log.LogTaskProperty ("OutputPath", OutputPath); + Log.LogTaskProperty ("SdkRoot", SdkRoot); + Log.LogTaskProperty ("TargetFrameworkIdentifier", TargetFrameworkIdentifier); + Log.LogTaskProperty ("TargetFrameworkVersion", TargetFrameworkVersion); + Log.LogTaskProperty ("TLSProvider", TLSProvider); + Log.LogTaskProperty ("UseXamMacFullFramework", UseXamMacFullFramework); + Log.LogTaskProperty ("Profiling", Profiling); + Log.LogTaskProperty ("AppManifest", AppManifest); + Log.LogTaskProperty ("SdkVersion", SdkVersion); + Log.LogTaskProperty ("NativeReferences", NativeReferences); + + return base.Execute (); + } + + protected override void LogEventsFromTextOutput (string singleLine, MessageImportance messageImportance) + { + try { // We first try to use the base logic, which shows up nicely in XS. + base.LogEventsFromTextOutput (singleLine, messageImportance); + } + catch { // But when that fails, just output the message to the command line and XS will output it raw + Log.LogMessage (messageImportance, "{0}", singleLine); + } + } + } +} diff --git a/msbuild/Xamarin.Mac.Tasks/Tasks/XamMacArch.cs b/msbuild/Xamarin.Mac.Tasks.Core/Tasks/XamMacArch.cs similarity index 100% rename from msbuild/Xamarin.Mac.Tasks/Tasks/XamMacArch.cs rename to msbuild/Xamarin.Mac.Tasks.Core/Tasks/XamMacArch.cs diff --git a/msbuild/Xamarin.Mac.Tasks.Core/Xamarin.Mac.Tasks.Core.csproj b/msbuild/Xamarin.Mac.Tasks.Core/Xamarin.Mac.Tasks.Core.csproj new file mode 100644 index 000000000000..72e33e2d44e4 --- /dev/null +++ b/msbuild/Xamarin.Mac.Tasks.Core/Xamarin.Mac.Tasks.Core.csproj @@ -0,0 +1,55 @@ + + + + Debug + AnyCPU + {AF1AC7C3-F6DD-4E46-B897-9DBB90B158EC} + Library + Xamarin.Mac.Tasks + Xamarin.Mac.Tasks.Core + 8.0.30703 + 2.0 + + + true + full + false + bin\Debug + DEBUG; + prompt + 4 + false + false + + + + + + + + + + + + + + + + + + + + + {CC3D9353-20C4-467A-8522-A9DED6F0C753} + Xamarin.MacDev + + + {534D7C5A-0E1C-4C58-9E48-21B1A98919EB} + Xamarin.MacDev.Tasks + + + {7B095849-6FDB-4BD2-9B59-569D81A1A809} + Xamarin.MacDev.Tasks.Core + + + \ No newline at end of file diff --git a/msbuild/Xamarin.Mac.Tasks/Tasks/DetectSdkLocations.cs b/msbuild/Xamarin.Mac.Tasks/Tasks/DetectSdkLocations.cs index 82576f2b14a2..cfb8e2c06222 100644 --- a/msbuild/Xamarin.Mac.Tasks/Tasks/DetectSdkLocations.cs +++ b/msbuild/Xamarin.Mac.Tasks/Tasks/DetectSdkLocations.cs @@ -10,134 +10,8 @@ namespace Xamarin.Mac.Tasks { - public class DetectSdkLocations : Task + public class DetectSdkLocations : DetectSdkLocationsTaskBase { - #region Inputs - // This is also an input - [Output] - public string SdkVersion { - get; set; - } - - public string XamarinSdkRoot { - get; set; - } - - #endregion Inputs - - #region Outputs - - [Output] - public string SdkRoot { - get; set; - } - - [Output] - public string SdkBinPath { - get; set; - } - - [Output] - public string SdkDevPath { - get; set; - } - - [Output] - public string SdkUsrPath { - get; set; - } - - #endregion Outputs - - public override bool Execute () - { - Log.LogTaskName ("DetectSdkLocations"); - Log.LogTaskProperty ("SdkVersion", SdkVersion); - Log.LogTaskProperty ("XamarinSdkRoot", XamarinSdkRoot); - - EnsureAppleSdkRoot (); - EnsureXamarinSdkRoot (); - EnsureSdkPath (); - - return !Log.HasLoggedErrors; - } - - void EnsureSdkPath () - { - MacOSXSdkVersion requestedSdkVersion; - if (string.IsNullOrEmpty (SdkVersion)) { - requestedSdkVersion = MacOSXSdkVersion.UseDefault; - } else if (!MacOSXSdkVersion.TryParse (SdkVersion, out requestedSdkVersion)) { - Log.LogError ("Could not parse the SDK version '{0}'", SdkVersion); - return; - } - - var sdkVersion = requestedSdkVersion.ResolveIfDefault (MacOSXSdks.Native); - if (!MacOSXSdks.Native.SdkIsInstalled (sdkVersion)) { - sdkVersion = MacOSXSdks.Native.GetClosestInstalledSdk (sdkVersion); - - if (sdkVersion.IsUseDefault || !MacOSXSdks.Native.SdkIsInstalled (sdkVersion)) { - if (requestedSdkVersion.IsUseDefault) { - Log.LogError ("The Apple MacOSX SDK is not installed."); - } else { - Log.LogError ("The MacOSX SDK version '{0}' is not installed, and no newer version was found.", requestedSdkVersion.ToString ()); - } - return; - } - Log.LogWarning ("The MacOSX SDK version '{0}' is not installed. Using newer version '{1}' instead'.", requestedSdkVersion, sdkVersion); - } - - SdkVersion = sdkVersion.ToString (); - - SdkRoot = MacOSXSdks.Native.GetSdkPath (sdkVersion); - if (string.IsNullOrEmpty (SdkRoot)) - Log.LogError ("Could not locate the MacOSX '{0}' SDK at path '{1}'", SdkVersion, SdkRoot); - - SdkUsrPath = DirExists ("SDK usr directory", Path.Combine (MacOSXSdks.Native.DeveloperRoot, "usr")); - if (string.IsNullOrEmpty (SdkUsrPath)) - Log.LogError ("Could not locate the MacOSX '{0}' SDK usr path at '{1}'", SdkVersion, SdkRoot); - - SdkBinPath = DirExists ("SDK bin directory", Path.Combine (SdkUsrPath, "bin")); - if (string.IsNullOrEmpty (SdkBinPath)) - Log.LogError ("Could not locate SDK bin directory"); - } - - void EnsureAppleSdkRoot () - { - if (!MacOSXSdks.Native.IsInstalled) { - Log.LogError (" Could not find valid a usable Xcode app bundle"); - } else { - Log.LogMessage (MessageImportance.Low, " DeveloperRoot: {0}", MacOSXSdks.Native.DeveloperRoot); - Log.LogMessage (MessageImportance.Low, " GetPlatformPath: {0}", MacOSXSdks.Native.GetPlatformPath ()); - - SdkDevPath = MacOSXSdks.Native.DeveloperRoot; - if (string.IsNullOrEmpty (SdkDevPath)) - Log.LogError (" Could not find valid a usable Xcode developer path"); - } - } - - void EnsureXamarinSdkRoot () - { - if (string.IsNullOrEmpty (XamarinSdkRoot)) - XamarinSdkRoot = MacOSXSdks.XamMac.FrameworkDirectory; - - if (string.IsNullOrEmpty (XamarinSdkRoot) || !Directory.Exists (XamarinSdkRoot)) - Log.LogError (" Could not find 'Xamarin.Mac'"); - } - - string DirExists (string checkingFor, params string[] paths) - { - try { - if (paths.Any (p => string.IsNullOrEmpty (p))) - return null; - - var path = Path.GetFullPath (Path.Combine (paths)); - Log.LogMessage (MessageImportance.Low, " Searching for '{0}' in '{1}'", checkingFor, path); - return Directory.Exists (path) ? path : null; - } catch { - return null; - } - } } } diff --git a/msbuild/Xamarin.Mac.Tasks/Tasks/EmbedProvisionProfile.cs b/msbuild/Xamarin.Mac.Tasks/Tasks/EmbedProvisionProfile.cs index 31f493a93c69..078e9afda65f 100644 --- a/msbuild/Xamarin.Mac.Tasks/Tasks/EmbedProvisionProfile.cs +++ b/msbuild/Xamarin.Mac.Tasks/Tasks/EmbedProvisionProfile.cs @@ -10,48 +10,8 @@ namespace Xamarin.Mac.Tasks { - public class EmbedProvisionProfile : Task + public class EmbedProvisionProfile : EmbedProvisionProfileTaskBase { - #region Inputs - [Required] - public string AppBundleDir { get; set; } - - [Required] - public string ProvisioningProfile { get; set; } - - #endregion - - static MobileProvision GetMobileProvision (MobileProvisionPlatform platform, string uuid) - { - var extension = MobileProvision.GetFileExtension (platform); - var path = Path.Combine (MobileProvision.ProfileDirectory, uuid + extension); - - if (File.Exists (path)) - return MobileProvision.LoadFromFile (path); - - return MobileProvision.GetAllInstalledProvisions (platform, true).FirstOrDefault (x => x.Uuid == uuid); - } - - public override bool Execute () - { - Log.LogTaskName ("EmbedProvisionProfile"); - Log.LogTaskProperty ("AppBundleDir", AppBundleDir); - Log.LogTaskProperty ("ProvisioningProfile", ProvisioningProfile); - - var profile = GetMobileProvision (MobileProvisionPlatform.MacOS, ProvisioningProfile); - - if (profile == null) { - Log.LogError ("Could not locate the provisioning profile with a UUID of {0}.", ProvisioningProfile); - return false; - } - - var embedded = Path.Combine (AppBundleDir, "Contents", "embedded.provisionprofile"); - - Directory.CreateDirectory (AppBundleDir); - profile.Save (embedded); - - return true; - } } } diff --git a/msbuild/Xamarin.Mac.Tasks/Tasks/Mmp.cs b/msbuild/Xamarin.Mac.Tasks/Tasks/Mmp.cs index 8d5de2cc05e3..d162f6e8a351 100644 --- a/msbuild/Xamarin.Mac.Tasks/Tasks/Mmp.cs +++ b/msbuild/Xamarin.Mac.Tasks/Tasks/Mmp.cs @@ -17,211 +17,7 @@ namespace Xamarin.Mac.Tasks { - public class Mmp : ToolTask + public class Mmp : MmpTaskBase { - protected override string ToolName { - get { return "mmp"; } - } - - [Required] - public string FrameworkRoot { get; set; } - - [Required] - public string OutputPath { get; set; } - - [Required] - public string ApplicationAssembly { get; set; } - - [Required] - public string HttpClientHandler { get; set; } - - [Required] - public string TargetFrameworkIdentifier { get; set; } - - [Required] - public string TargetFrameworkVersion { get; set; } - - [Required] - public string TLSProvider { get; set; } - - [Required] - public string SdkRoot { get; set; } - - [Required] - public ITaskItem AppManifest { get; set; } - - [Required] - public string SdkVersion { get; set; } - - public bool UseXamMacFullFramework { get; set; } - - public string ApplicationName { get; set; } - public string Architecture { get; set; } - public string LinkMode { get; set; } - public bool Debug { get; set; } - public bool Profiling { get; set; } - public string I18n { get; set; } - public string ExtraArguments { get; set; } - - public string [] ExplicitReferences { get; set; } - public string [] NativeReferences { get; set; } - - public string IntermediateOutputPath { get; set; } - - protected override string GenerateFullPathToTool () - { - return Path.Combine (FrameworkRoot, "bin", "mmp"); - } - - protected override bool ValidateParameters () - { - XamMacArch arch; - return Enum.TryParse (Architecture, true, out arch); - } - - protected override string GenerateCommandLineCommands () - { - var args = new ProcessArgumentBuilder (); - - args.Add ("/verbose"); - - if (Debug) - args.Add ("/debug"); - - if (!string.IsNullOrEmpty (OutputPath)) - args.AddQuoted ("/output:" + Path.GetFullPath (OutputPath)); - - if (!string.IsNullOrEmpty (ApplicationName)) - args.AddQuoted ("/name:" + ApplicationName); - - if (TargetFrameworkIdentifier == "Xamarin.Mac") - args.Add ("/profile:Xamarin.Mac"); - else if (TargetFrameworkVersion.StartsWith ("v", StringComparison.Ordinal)) - args.Add ("/profile:" + TargetFrameworkVersion.Substring (1)); - - if (TargetFrameworkIdentifier == "Xamarin.Mac" || UseXamMacFullFramework) { - XamMacArch arch; - if (!Enum.TryParse (Architecture, true, out arch)) - arch = XamMacArch.Default; - - if (arch == XamMacArch.Default) - arch = XamMacArch.x86_64; - - if (arch.HasFlag (XamMacArch.i386)) - args.Add ("/arch:i386"); - - if (arch.HasFlag (XamMacArch.x86_64)) - args.Add ("/arch:x86_64"); - } - else { - args.Add ("/arch:i386"); - } - - args.Add (string.Format ("--http-message-handler={0}", HttpClientHandler)); - - if (AppManifest != null) { - try { - var plist = PDictionary.FromFile (AppManifest.ItemSpec); - - PString v; - string minimumDeploymentTarget; - - if (!plist.TryGetValue (ManifestKeys.LSMinimumSystemVersion, out v) || string.IsNullOrEmpty (v.Value)) - minimumDeploymentTarget = SdkVersion; - else - minimumDeploymentTarget = v.Value; - - args.Add (string.Format("/minos={0}", minimumDeploymentTarget)); - } - catch (Exception ex) { - Log.LogWarning (null, null, null, AppManifest.ItemSpec, 0, 0, 0, 0, "Error loading '{0}': {1}", AppManifest.ItemSpec, ex.Message); - } - } - - if (TargetFrameworkIdentifier == "Xamarin.Mac" && !string.IsNullOrEmpty (TLSProvider)) - args.Add (string.Format ("--tls-provider={0}", TLSProvider.ToLowerInvariant())); - - if (Profiling) - args.Add ("/profiling"); - - switch ((LinkMode ?? String.Empty).ToLower ()) { - case "full": - break; - case "sdkonly": - args.Add ("/linksdkonly"); - break; - default: - args.Add ("/nolink"); - break; - } - - if (!string.IsNullOrEmpty (I18n)) - args.AddQuoted ("/i18n:" + I18n); - - if (ExplicitReferences != null) { - foreach (var asm in ExplicitReferences) - args.AddQuoted ("/assembly:" + Path.GetFullPath (asm)); - } - - if (!string.IsNullOrEmpty (ApplicationAssembly)) - args.AddQuoted (Path.GetFullPath (ApplicationAssembly)); - - if (!string.IsNullOrWhiteSpace (ExtraArguments)) - args.Add (ExtraArguments); - - if (NativeReferences != null) { - foreach (var nr in NativeReferences) - args.AddQuoted ("/native-reference:" + Path.GetFullPath (nr)); - } - - args.Add ("/sdkroot"); - args.AddQuoted (SdkRoot); - - if (!string.IsNullOrEmpty (IntermediateOutputPath)) { - Directory.CreateDirectory (IntermediateOutputPath); - - args.Add ("--cache"); - args.AddQuoted (Path.GetFullPath (IntermediateOutputPath)); - } - - return args.ToString (); - } - - public override bool Execute () - { - Log.LogTaskName ("Mmp"); - Log.LogTaskProperty ("ApplicationAssembly", ApplicationAssembly); - Log.LogTaskProperty ("ApplicationName", ApplicationName); - Log.LogTaskProperty ("Architecture", Architecture); - Log.LogTaskProperty ("Debug", Debug); - Log.LogTaskProperty ("ExplicitReferences", ExplicitReferences); - Log.LogTaskProperty ("ExtraArguments", ExtraArguments); - Log.LogTaskProperty ("FrameworkRoot", FrameworkRoot); - Log.LogTaskProperty ("I18n", I18n); - Log.LogTaskProperty ("IntermediateOutputPath", IntermediateOutputPath); - Log.LogTaskProperty ("LinkMode", LinkMode); - Log.LogTaskProperty ("OutputPath", OutputPath); - Log.LogTaskProperty ("SdkRoot", SdkRoot); - Log.LogTaskProperty ("TargetFrameworkIdentifier", TargetFrameworkIdentifier); - Log.LogTaskProperty ("TargetFrameworkVersion", TargetFrameworkVersion); - Log.LogTaskProperty ("TLSProvider", TLSProvider); - Log.LogTaskProperty ("UseXamMacFullFramework", UseXamMacFullFramework); - Log.LogTaskProperty ("Profiling", Profiling); - Log.LogTaskProperty ("AppManifest", AppManifest); - Log.LogTaskProperty ("SdkVersion", SdkVersion); - Log.LogTaskProperty ("NativeReferences", NativeReferences); - - return base.Execute (); - } - - protected override void LogEventsFromTextOutput (string singleLine, MessageImportance messageImportance) - { - try { // We first try to use the base logic, which shows up nicely in XS. - base.LogEventsFromTextOutput (singleLine, messageImportance); - } - catch { // But when that fails, just output the message to the command line and XS will output it raw - Log.LogMessage (messageImportance, "{0}", singleLine); - } - } } } diff --git a/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.targets b/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.targets index 93916048a36f..757d68be7679 100644 --- a/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.targets +++ b/msbuild/Xamarin.Mac.Tasks/Xamarin.Mac.Common.targets @@ -161,7 +161,8 @@ Copyright (C) 2014 Xamarin. All rights reserved. - - @@ -185,7 +187,8 @@ Copyright (C) 2014 Xamarin. All rights reserved. - - - - - @@ -244,13 +251,15 @@ Copyright (C) 2014 Xamarin. All rights reserved. - @@ -292,7 +304,8 @@ Copyright (C) 2014 Xamarin. All rights reserved. - @@ -306,7 +319,8 @@ Copyright (C) 2014 Xamarin. All rights reserved. - - - @@ -345,7 +361,8 @@ Copyright (C) 2014 Xamarin. All rights reserved. - - + @@ -366,7 +385,8 @@ Copyright (C) 2014 Xamarin. All rights reserved. - - - - @@ -449,7 +472,8 @@ Copyright (C) 2014 Xamarin. All rights reserved. Outputs="$(IntermediateOutputPath)%(_ColladaAssetWithLogicalName.LogicalName)" > - - - - + Debug @@ -27,6 +27,10 @@ + + False + ..\..\..\XamarinVS\lib\Mac\MsBuild\Xamarin.Mac.Tasks.Core.dll + @@ -35,7 +39,6 @@ - @@ -52,12 +55,9 @@ - - - - + {CC3D9353-20C4-467A-8522-A9DED6F0C753} @@ -98,4 +98,4 @@ PreserveNewest - + \ No newline at end of file diff --git a/msbuild/Xamarin.MacDev.Tasks.sln b/msbuild/Xamarin.MacDev.Tasks.sln index fbccde150489..824ef0f38768 100644 --- a/msbuild/Xamarin.MacDev.Tasks.sln +++ b/msbuild/Xamarin.MacDev.Tasks.sln @@ -1,6 +1,8 @@  -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual Studio 2010 +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.iOS.Tasks.Core", "Xamarin.iOS.Tasks.Core\Xamarin.iOS.Tasks.Core.csproj", "{93E12FA0-089C-4BC8-840F-43CFBC7927C7}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.iOS.Tasks.Tests", "tests\Xamarin.iOS.Tasks.Tests\Xamarin.iOS.Tasks.Tests.csproj", "{EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}" @@ -17,44 +19,50 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.iOS.Tasks", "Xamari EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.MacDev.Tasks.Core", "Xamarin.MacDev.Tasks.Core\Xamarin.MacDev.Tasks.Core.csproj", "{7B095849-6FDB-4BD2-9B59-569D81A1A809}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xamarin.Mac.Tasks.Core", "Xamarin.Mac.Tasks.Core\Xamarin.Mac.Tasks.Core.csproj", "{AF1AC7C3-F6DD-4E46-B897-9DBB90B158EC}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {44605724-8002-48E1-895F-7CB068099B6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {44605724-8002-48E1-895F-7CB068099B6A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {44605724-8002-48E1-895F-7CB068099B6A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {44605724-8002-48E1-895F-7CB068099B6A}.Release|Any CPU.Build.0 = Release|Any CPU - {534D7C5A-0E1C-4C58-9E48-21B1A98919EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {534D7C5A-0E1C-4C58-9E48-21B1A98919EB}.Debug|Any CPU.Build.0 = Debug|Any CPU - {534D7C5A-0E1C-4C58-9E48-21B1A98919EB}.Release|Any CPU.ActiveCfg = Release|Any CPU - {534D7C5A-0E1C-4C58-9E48-21B1A98919EB}.Release|Any CPU.Build.0 = Release|Any CPU - {CC3D9353-20C4-467A-8522-A9DED6F0C753}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CC3D9353-20C4-467A-8522-A9DED6F0C753}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CC3D9353-20C4-467A-8522-A9DED6F0C753}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CC3D9353-20C4-467A-8522-A9DED6F0C753}.Release|Any CPU.Build.0 = Release|Any CPU - {7B095849-6FDB-4BD2-9B59-569D81A1A809}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7B095849-6FDB-4BD2-9B59-569D81A1A809}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7B095849-6FDB-4BD2-9B59-569D81A1A809}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7B095849-6FDB-4BD2-9B59-569D81A1A809}.Release|Any CPU.Build.0 = Release|Any CPU {93E12FA0-089C-4BC8-840F-43CFBC7927C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {93E12FA0-089C-4BC8-840F-43CFBC7927C7}.Debug|Any CPU.Build.0 = Debug|Any CPU {93E12FA0-089C-4BC8-840F-43CFBC7927C7}.Release|Any CPU.ActiveCfg = Release|Any CPU {93E12FA0-089C-4BC8-840F-43CFBC7927C7}.Release|Any CPU.Build.0 = Release|Any CPU - {C566CA0D-D0EF-4C33-86D3-049DDD9F1831}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C566CA0D-D0EF-4C33-86D3-049DDD9F1831}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C566CA0D-D0EF-4C33-86D3-049DDD9F1831}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C566CA0D-D0EF-4C33-86D3-049DDD9F1831}.Release|Any CPU.Build.0 = Release|Any CPU - {C8D98DC1-5122-4B10-A152-17196C7BD9AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C8D98DC1-5122-4B10-A152-17196C7BD9AC}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C8D98DC1-5122-4B10-A152-17196C7BD9AC}.Release|Any CPU.ActiveCfg = Debug|Any CPU - {C8D98DC1-5122-4B10-A152-17196C7BD9AC}.Release|Any CPU.Build.0 = Debug|Any CPU {EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Debug|Any CPU.Build.0 = Debug|Any CPU {EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Release|Any CPU.ActiveCfg = Release|Any CPU {EDB0E879-5AE6-4E2B-925D-F59023A6AA8D}.Release|Any CPU.Build.0 = Release|Any CPU + {CC3D9353-20C4-467A-8522-A9DED6F0C753}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CC3D9353-20C4-467A-8522-A9DED6F0C753}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CC3D9353-20C4-467A-8522-A9DED6F0C753}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CC3D9353-20C4-467A-8522-A9DED6F0C753}.Release|Any CPU.Build.0 = Release|Any CPU + {534D7C5A-0E1C-4C58-9E48-21B1A98919EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {534D7C5A-0E1C-4C58-9E48-21B1A98919EB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {534D7C5A-0E1C-4C58-9E48-21B1A98919EB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {534D7C5A-0E1C-4C58-9E48-21B1A98919EB}.Release|Any CPU.Build.0 = Release|Any CPU + {C8D98DC1-5122-4B10-A152-17196C7BD9AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C8D98DC1-5122-4B10-A152-17196C7BD9AC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C8D98DC1-5122-4B10-A152-17196C7BD9AC}.Release|Any CPU.ActiveCfg = Debug|Any CPU + {C8D98DC1-5122-4B10-A152-17196C7BD9AC}.Release|Any CPU.Build.0 = Debug|Any CPU + {C566CA0D-D0EF-4C33-86D3-049DDD9F1831}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C566CA0D-D0EF-4C33-86D3-049DDD9F1831}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C566CA0D-D0EF-4C33-86D3-049DDD9F1831}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C566CA0D-D0EF-4C33-86D3-049DDD9F1831}.Release|Any CPU.Build.0 = Release|Any CPU + {44605724-8002-48E1-895F-7CB068099B6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {44605724-8002-48E1-895F-7CB068099B6A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {44605724-8002-48E1-895F-7CB068099B6A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {44605724-8002-48E1-895F-7CB068099B6A}.Release|Any CPU.Build.0 = Release|Any CPU + {7B095849-6FDB-4BD2-9B59-569D81A1A809}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7B095849-6FDB-4BD2-9B59-569D81A1A809}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7B095849-6FDB-4BD2-9B59-569D81A1A809}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7B095849-6FDB-4BD2-9B59-569D81A1A809}.Release|Any CPU.Build.0 = Release|Any CPU + {AF1AC7C3-F6DD-4E46-B897-9DBB90B158EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF1AC7C3-F6DD-4E46-B897-9DBB90B158EC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF1AC7C3-F6DD-4E46-B897-9DBB90B158EC}.Release|Any CPU.ActiveCfg = Debug|Any CPU + {AF1AC7C3-F6DD-4E46-B897-9DBB90B158EC}.Release|Any CPU.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE