Merge remote-tracking branch 'upstream/master' into mono-2019-02

This commit is contained in:
Alexander Köplinger 2019-04-17 11:29:35 +02:00
Родитель d405c37692 cf8d42e4c0
Коммит 0da0bcaaae
11 изменённых файлов: 141 добавлений и 7 удалений

Просмотреть файл

@ -0,0 +1,74 @@
using System;
using System.IO;
using System.Diagnostics;
using Microsoft.Build.Framework;
using Microsoft.Build.Utilities;
using Xamarin.MacDev;
using Xamarin.MacDev.Tasks;
namespace Xamarin.Mac.Tasks
{
public abstract class ArchiveTaskBase : Xamarin.MacDev.Tasks.ArchiveTaskBase
{
public override bool Execute ()
{
var archiveDir = CreateArchiveDirectory ();
try {
var plist = PDictionary.FromFile (Path.Combine (AppBundleDir.ItemSpec, "Contents", "Info.plist"));
var productsDir = Path.Combine (archiveDir, "Products");
// Archive the Applications...
var appDestDir = Path.Combine (productsDir, "Applications", Path.GetFileName (AppBundleDir.ItemSpec));
Ditto (AppBundleDir.ItemSpec, appDestDir);
// Archive the dSYMs...
if (Directory.Exists (DSYMDir)) {
var destDir = Path.Combine (archiveDir, "dSYMs", Path.GetFileName (DSYMDir));
Ditto (DSYMDir, destDir);
}
// Generate an archive Info.plist
var arInfo = new PDictionary ();
var props = new PDictionary ();
props.Add ("ApplicationPath", new PString (string.Format ("Applications/{0}", Path.GetFileName (AppBundleDir.ItemSpec))));
props.Add ("CFBundleIdentifier", new PString (plist.GetCFBundleIdentifier ()));
var version = plist.GetCFBundleShortVersionString ();
var build = plist.GetCFBundleVersion ();
props.Add ("CFBundleShortVersionString", new PString (version ?? (build ?? "1.0")));
props.Add ("CFBundleVersion", new PString (build ?? "1.0"));
props.Add ("SigningIdentity", SigningKey);
arInfo.Add ("ApplicationProperties", props);
arInfo.Add ("ArchiveVersion", new PNumber (2));
arInfo.Add ("CreationDate", new PDate (Now.ToUniversalTime ()));
arInfo.Add ("Name", new PString (plist.GetCFBundleName () ?? plist.GetCFBundleDisplayName ()));
if (!string.IsNullOrEmpty (ProjectGuid))
arInfo.Add ("ProjectGuid", new PString (ProjectGuid));
if (!string.IsNullOrEmpty (ProjectTypeGuids))
arInfo.Add ("ProjectTypeGuids", new PString (ProjectTypeGuids));
if (!string.IsNullOrEmpty (SolutionPath)) {
arInfo.Add ("SolutionName", new PString (Path.GetFileNameWithoutExtension (SolutionPath)));
arInfo.Add ("SolutionPath", new PString (SolutionPath));
}
if (!string.IsNullOrEmpty (InsightsApiKey))
arInfo.Add ("InsightsApiKey", new PString (InsightsApiKey));
arInfo.Save (Path.Combine (archiveDir, "Info.plist"));
ArchiveDir = archiveDir;
} catch (Exception ex) {
Log.LogErrorFromException (ex);
Directory.Delete (archiveDir, true);
}
return !Log.HasLoggedErrors;
}
}
}

Просмотреть файл

@ -37,6 +37,7 @@
<Compile Include="Tasks\EmbedProvisionProfileTaskBase.cs" />
<Compile Include="Tasks\MmpTaskBase.cs" />
<Compile Include="Tasks\XamMacArch.cs" />
<Compile Include="Tasks\ArchiveTaskBase.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\external\Xamarin.MacDev\Xamarin.MacDev\Xamarin.MacDev.csproj">

Просмотреть файл

@ -0,0 +1,6 @@
namespace Xamarin.Mac.Tasks
{
public class Archive : ArchiveTaskBase
{
}
}

Просмотреть файл

@ -84,6 +84,7 @@ Copyright (C) 2013-2014 Xamarin. All rights reserved.
<IsAppExtension Condition="'$(IsAppExtension)' == ''">False</IsAppExtension>
<EnableSGenConc Condition="'$(EnableSGenConc)' == ''">false</EnableSGenConc>
<AotScope Condition="'$(AotScope)' == ''">None</AotScope>
<ArchiveOnBuild Condition="'$(ArchiveOnBuild)' == ''">False</ArchiveOnBuild>
</PropertyGroup>
<PropertyGroup>

Просмотреть файл

@ -31,6 +31,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
<UsingTask TaskName="Xamarin.MacDev.Tasks.SmartCopy" AssemblyFile="Xamarin.Mac.Tasks.dll" />
<UsingTask TaskName="Xamarin.MacDev.Tasks.UnpackLibraryResources" AssemblyFile="Xamarin.Mac.Tasks.dll" />
<UsingTask TaskName="Xamarin.MacDev.Tasks.WriteItemsToFile" AssemblyFile="Xamarin.Mac.Tasks.dll" />
<UsingTask TaskName="Xamarin.Mac.Tasks.Archive" AssemblyFile="Xamarin.Mac.Tasks.dll" />
<UsingTask TaskName="Xamarin.Mac.Tasks.ACTool" AssemblyFile="Xamarin.Mac.Tasks.dll" />
<UsingTask TaskName="Xamarin.Mac.Tasks.CodesignVerify" AssemblyFile="Xamarin.Mac.Tasks.dll" />
<UsingTask TaskName="Xamarin.Mac.Tasks.CompileAppManifest" AssemblyFile="Xamarin.Mac.Tasks.dll" />
@ -109,6 +110,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
_CreateAppBundle;
Codesign;
_CreateInstaller;
Archive;
</BuildDependsOn>
</PropertyGroup>
@ -811,6 +813,31 @@ Copyright (C) 2014 Xamarin. All rights reserved.
Condition="'@(_AppExtensionReferenceWithConfigurationNonExistent)' != ''"/>
</Target>
<PropertyGroup>
<ArchiveDependsOn>
_CoreArchive
</ArchiveDependsOn>
</PropertyGroup>
<Target Name="Archive" Condition="'$(_CanArchive)' == 'true'" DependsOnTargets="$(ArchiveDependsOn)" />
<Target Name="_CoreArchive" Condition="'$(ArchiveOnBuild)' == 'true'" DependsOnTargets="$(Codesign)">
<Error Text="Code signing must be enabled to create an Xcode archive." Condition="'$(_CodeSigningKey)' == ''" />
<Archive
SessionId="$(BuildSessionId)"
AppBundleDir="$(AppBundleDir)"
InsightsApiKey="$(XamarinInsightsApiKey)"
SigningKey="$(_CodeSigningKey)"
ProjectName="$(MSBuildProjectName)"
ProjectGuid="$(ProjectGuid)"
ProjectTypeGuids="$(ProjectTypeGuids)"
OutputPath="$(OutputPath)"
>
<Output TaskParameter="ArchiveDir" PropertyName="ArchiveDir" />
</Archive>
</Target>
<Import Project="$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets"
Condition="Exists('$(MSBuildThisFileDirectory)$(MSBuildThisFileName).After.targets')"/>
</Project>

Просмотреть файл

@ -47,6 +47,7 @@
<Compile Include="Tasks\ScnTool.cs" />
<Compile Include="Tasks\TextureAtlas.cs" />
<Compile Include="Tasks\PrepareNativeReferences.cs" />
<Compile Include="Tasks\Archive.cs" />
</ItemGroup>
<ItemGroup />
<ItemGroup>

Просмотреть файл

@ -22,9 +22,6 @@ namespace Xamarin.MacDev.Tasks
public string InsightsApiKey { get; set; }
[Required]
public ITaskItem[] ITunesSourceFiles { get; set; }
[Required]
public string OutputPath { get; set; }

Просмотреть файл

@ -12,6 +12,9 @@ namespace Xamarin.iOS.Tasks
{
public class ArchiveTaskBase : Xamarin.MacDev.Tasks.ArchiveTaskBase
{
[Required]
public ITaskItem[] ITunesSourceFiles { get; set; }
public ITaskItem[] AppExtensionReferences { get; set; }
public ITaskItem[] WatchAppReferences { get; set; }

Просмотреть файл

@ -238,7 +238,7 @@ namespace Xamarin.MMP.Tests
RunAndAssert (Configuration.XIBuildPath, new StringBuilder ("-- " + csprojTarget + " /t:clean"), "Clean");
}
public static string BuildProject (string csprojTarget, bool isUnified, bool shouldFail = false, bool release = false, string[] environment = null)
public static string BuildProject (string csprojTarget, bool isUnified, bool shouldFail = false, bool release = false, string[] environment = null, string extraArgs = "")
{
string rootDirectory = FindRootDirectory ();
@ -264,6 +264,9 @@ namespace Xamarin.MMP.Tests
buildArgs.Append (" build ");
}
if (!string.IsNullOrEmpty (extraArgs))
buildArgs.Append (extraArgs);
buildArgs.Append (StringUtils.Quote (csprojTarget));
Func <string> getBuildProjectErrorInfo = () => {

Просмотреть файл

@ -737,5 +737,25 @@ namespace Xamarin.MMP.Tests
});
}
[TestCase (false)]
[TestCase (true)]
public void ArchiveTask (bool full)
{
// https://github.com/xamarin/xamarin-macios/issues/5653
if (TI.InJenkins)
Assert.Ignore ("Requires macOS entitlements on bots.");
RunMMPTest (tmpDir => {
TI.UnifiedTestConfig test = new TI.UnifiedTestConfig (tmpDir) {
XM45 = full,
CSProjConfig = "<EnableCodeSigning>true</EnableCodeSigning>"
};
TI.TestUnifiedExecutable (test);
var output = TI.BuildProject (Path.Combine (tmpDir, full ? "XM45Example.csproj" : "UnifiedExample.csproj"), true, release: true, extraArgs: "/p:ArchiveOnBuild=true ");
});
// TODO: Add something to validate the archive is loadable by Xcode
}
}
}

Просмотреть файл

@ -1,4 +1,5 @@
using System;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
@ -139,9 +140,9 @@ static class C {
case 'c':
case 's':
case 'i':
case 'l': return ((i + 1) * multiplier).ToString ();
case 'f': return (3.14f * (i + 1) * multiplier) + "f";
case 'd': return (1.23f * (i + 1) * multiplier).ToString ();
case 'l': return ((i + 1) * multiplier).ToString (CultureInfo.InvariantCulture);
case 'f': return (3.14f * (i + 1) * multiplier).ToString (CultureInfo.InvariantCulture) + "f";
case 'd': return (1.23f * (i + 1) * multiplier).ToString (CultureInfo.InvariantCulture);
default:
throw new NotImplementedException ();
}