Skip to content
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 @@ -17,6 +17,7 @@ Copyright (C) 2014-2016 Xamarin. All rights reserved.
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<IsAppExtension>True</IsAppExtension>
<AppBundleExtension>.appex</AppBundleExtension>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)Xamarin.TVOS.Common.targets" />
Expand All @@ -34,7 +35,7 @@ Copyright (C) 2014-2016 Xamarin. All rights reserved.

<Target Name="_GenerateBundleName" DependsOnTargets="_ComputeTargetArchitectures;_DetectSigningIdentity">
<PropertyGroup>
<AppBundleDir Condition="'$(AppBundleDir)' == ''">$(DeviceSpecificOutputPath)$(_AppBundleName).appex</AppBundleDir>
<AppBundleDir Condition="'$(AppBundleDir)' == ''">$(DeviceSpecificOutputPath)$(_AppBundleName)$(AppBundleExtension)</AppBundleDir>
<_AppBundlePath>$(AppBundleDir)\</_AppBundlePath>

<!-- needed for GetTargetPath/Build/Rebuild task outputs -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Copyright (C) 2015-2016 Xamarin. All rights reserved.
<PropertyGroup>
<IsAppExtension>True</IsAppExtension>
<IsWatchExtension>True</IsWatchExtension>
<AppBundleExtension>.appex</AppBundleExtension>
<MtouchHttpClientHandler Condition="'$(MtouchHttpClientHandler)' == ''">NSUrlSessionHandler</MtouchHttpClientHandler>
</PropertyGroup>

Expand All @@ -36,7 +37,7 @@ Copyright (C) 2015-2016 Xamarin. All rights reserved.

<Target Name="_GenerateBundleName" DependsOnTargets="_ComputeTargetArchitectures;_DetectSigningIdentity">
<PropertyGroup>
<AppBundleDir Condition="'$(AppBundleDir)' == ''">$(DeviceSpecificOutputPath)$(_AppBundleName).appex</AppBundleDir>
<AppBundleDir Condition="'$(AppBundleDir)' == ''">$(DeviceSpecificOutputPath)$(_AppBundleName)$(AppBundleExtension)</AppBundleDir>
<_AppBundlePath>$(AppBundleDir)\</_AppBundlePath>

<!-- needed for GetTargetPath/Build/Rebuild task outputs -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Copyright (C) 2014-2016 Xamarin. All rights reserved.
<PropertyGroup>
<IsAppExtension>True</IsAppExtension>
<IsWatchExtension>False</IsWatchExtension>
<AppBundleExtension>.appex</AppBundleExtension>
</PropertyGroup>

<Import Project="$(MSBuildThisFileDirectory)Xamarin.iOS.Common.targets" />
Expand All @@ -35,7 +36,7 @@ Copyright (C) 2014-2016 Xamarin. All rights reserved.

<Target Name="_GenerateBundleName" DependsOnTargets="_ComputeTargetArchitectures;_DetectSigningIdentity">
<PropertyGroup>
<AppBundleDir Condition="'$(AppBundleDir)' == ''">$(DeviceSpecificOutputPath)$(_AppBundleName).appex</AppBundleDir>
<AppBundleDir Condition="'$(AppBundleDir)' == ''">$(DeviceSpecificOutputPath)$(_AppBundleName)$(AppBundleExtension)</AppBundleDir>
<_AppBundlePath>$(AppBundleDir)\</_AppBundlePath>

<!-- needed for GetTargetPath/Build/Rebuild task outputs -->
Expand Down
86 changes: 75 additions & 11 deletions msbuild/Xamarin.iOS.Tasks.Core/Xamarin.iOS.Common.targets
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
<_PreparedResourceRules></_PreparedResourceRules>
<_AppBundleName>$(AssemblyName)</_AppBundleName>

<AppBundleExtension Condition="'$(AppBundleExtension)' == ''">.app</AppBundleExtension>

<DeviceSpecificIntermediateOutputPath>$(IntermediateOutputPath)</DeviceSpecificIntermediateOutputPath>
<DeviceSpecificOutputPath>$(OutputPath)</DeviceSpecificOutputPath>
</PropertyGroup>
Expand Down Expand Up @@ -307,6 +309,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.

<_CoreCodesignDependsOn>
_CodesignNativeLibraries;
_CollectFrameworks;
_CodesignFrameworks;
_CodesignAppExtensions;
_CodesignAppBundle;
Expand Down Expand Up @@ -373,6 +376,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
Condition="'$(IsMacEnabled)' == 'true'"
Directories="$(DeviceSpecificIntermediateOutputPath)actool;
$(DeviceSpecificIntermediateOutputPath)assetpacks;
$(DeviceSpecificIntermediateOutputPath)codesign;
$(DeviceSpecificIntermediateOutputPath)ibtool;
$(DeviceSpecificIntermediateOutputPath)ibtool-link;
$(DeviceSpecificIntermediateOutputPath)ibtool-manifests;
Expand Down Expand Up @@ -589,7 +593,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.

<Target Name="_GenerateBundleName" Condition="'$(_CanOutputAppBundle)' == 'true'" DependsOnTargets="_ComputeTargetArchitectures">
<PropertyGroup>
<AppBundleDir>$(DeviceSpecificOutputPath)$(_AppBundleName).app</AppBundleDir>
<AppBundleDir>$(DeviceSpecificOutputPath)$(_AppBundleName)$(AppBundleExtension)</AppBundleDir>
<_AppBundlePath>$(AppBundleDir)\</_AppBundlePath>
</PropertyGroup>
</Target>
Expand Down Expand Up @@ -1599,15 +1603,15 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
Condition="'$(IsMacEnabled)' == 'true'"
AppBundlePath="$(_AppBundlePath)"
>

<Output TaskParameter="Frameworks" ItemName="_Frameworks"/>
</CollectFrameworks>
</Target>

<!-- Note: Always codesign *.dylibs even for Simulator builds. We use $(_CanOutputAppBundle) because dylibs can exist in app extensions as well. -->
<Target Name="_CodesignNativeLibraries" Condition="'$(_CanOutputAppBundle)' == 'true'" DependsOnTargets="_DetectSigningIdentity">
<Target Name="_CodesignNativeLibraries" Condition="'$(_CanOutputAppBundle)' == 'true' And '$(_CodeSigningKey)' != '' And '@(_NativeLibrary)' != ''" DependsOnTargets="_DetectSigningIdentity;_CompileToNative"
Inputs="%(_NativeLibrary.Identity)" Outputs="$(DeviceSpecificIntermediateOutputPath)codesign\%(_NativeLibrary.Filename)%(_NativeLibrary.Extension)">
<Codesign
Condition="'$(IsMacEnabled)' == 'true' And '@(_NativeLibrary)' != '' And '$(_CodeSigningKey)' != ''"
Condition="'$(IsMacEnabled)' == 'true'"
SessionId="$(BuildSessionId)"
ToolExe="$(CodesignExe)"
ToolPath="$(CodesignPath)"
Expand All @@ -1619,11 +1623,23 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
ExtraArgs="$(CodesignExtraArgs)"
>
</Codesign>

<MakeDir SessionId="$(BuildSessionId)" Condition="'$(IsMacEnabled)' == 'true'" Directories="$(DeviceSpecificIntermediateOutputPath)codesign" />

<Touch
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
AlwaysCreate="true"
Files="$(DeviceSpecificIntermediateOutputPath)codesign\%(_NativeLibrary.Filename)%(_NativeLibrary.Extension)"
>
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>
</Target>

<Target Name="_CodesignFrameworks" Condition="'$(_CanOutputAppBundle)' == 'true'" DependsOnTargets="_DetectSigningIdentity;_CollectFrameworks">
<Target Name="_CodesignFrameworks" Condition="'$(_CanOutputAppBundle)' == 'true' And '$(_CodeSigningKey)' != '' And '@(_Frameworks)' != ''" DependsOnTargets="_DetectSigningIdentity;_CollectFrameworks"
Inputs="%(_Frameworks.Identity)" Outputs="$(DeviceSpecificIntermediateOutputPath)codesign\%(_Frameworks.Filename)%(_Frameworks.Extension)">
<Codesign
Condition="'$(IsMacEnabled)' == 'true' And '@(_Frameworks)' != '' And '$(_CodeSigningKey)' != ''"
Condition="'$(IsMacEnabled)' == 'true'"
SessionId="$(BuildSessionId)"
ToolExe="$(CodesignExe)"
ToolPath="$(CodesignPath)"
Expand All @@ -1635,6 +1651,17 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
ExtraArgs="$(CodesignExtraArgs)"
>
</Codesign>

<MakeDir SessionId="$(BuildSessionId)" Condition="'$(IsMacEnabled)' == 'true'" Directories="$(DeviceSpecificIntermediateOutputPath)codesign" />

<Touch
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
AlwaysCreate="true"
Files="$(DeviceSpecificIntermediateOutputPath)codesign\%(_Frameworks.Filename)%(_Frameworks.Extension)"
>
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>
</Target>

<Target Name="_ReadAppExtensionCodesignProperties" DependsOnTargets="_CopyAppExtensionsToBundle">
Expand All @@ -1643,10 +1670,13 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
</ReadItemsFromFile>
</Target>

<Target Name="_CodesignAppExtensions" Condition="'$(_RequireCodeSigning)' == 'true' And '$(IsAppExtension)' == 'false' And ('$(OutputType)' == 'Exe' Or '$(IsWatchApp)' == 'true')" DependsOnTargets="_DetectSigningIdentity;_ReadAppExtensionCodesignProperties">
<Target Name="_CodesignAppExtensions" Condition="'$(_RequireCodeSigning)' == 'true' And '$(IsAppExtension)' == 'false' And ('$(OutputType)' == 'Exe' Or '$(IsWatchApp)' == 'true') And '@(_AppExtensionCodesignProperties)' != ''"
DependsOnTargets="_DetectSigningIdentity;_ReadAppExtensionCodesignProperties"
Inputs="$(_AppBundlePath)PlugIns\%(_AppExtensionCodesignProperties.Identity)"
Outputs="$(DeviceSpecificIntermediateOutputPath)codesign\%(_AppExtensionCodesignProperties.Identity)">
<Codesign
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' And '@(_AppExtensionCodesignProperties)' != ''"
Condition="'$(IsMacEnabled)' == 'true'"
ToolExe="$(CodesignExe)"
ToolPath="$(CodesignPath)"
CodesignAllocate="%(_AppExtensionCodesignProperties.CodesignAllocate)"
Expand All @@ -1660,6 +1690,17 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
>
</Codesign>

<MakeDir SessionId="$(BuildSessionId)" Condition="'$(IsMacEnabled)' == 'true'" Directories="$(DeviceSpecificIntermediateOutputPath)codesign" />

<Touch
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
AlwaysCreate="true"
Files="$(DeviceSpecificIntermediateOutputPath)codesign\%(_AppExtensionCodesignProperties.Identity)"
>
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>

<Touch
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' And '$(_RequireCodeSigning)' == 'true' And Exists ('$(AppBundleDir)\..\%(_AppExtensionCodesignProperties.Identity).dSYM\Contents\Info.plist')"
Expand Down Expand Up @@ -1701,10 +1742,12 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
/>
</Target>

<Target Name="_CodesignAppBundle" Condition="'$(_RequireCodeSigning)' == 'true'" DependsOnTargets="$(_CodesignAppBundleDependsOn);_PrepareCodesignAppBundle">
<Target Name="_CodesignAppBundle" Condition="'$(_RequireCodeSigning)' == 'true' And '$(IsAppExtension)' == 'false'" DependsOnTargets="$(_CodesignAppBundleDependsOn);_PrepareCodesignAppBundle"
Inputs="%(_NativeExecutable.Identity);$(DeviceSpecificIntermediateOutputPath)Entitlements.xcent;@(_BundleResourceWithLogicalName)"
Outputs="$(DeviceSpecificIntermediateOutputPath)codesign\$(_AppBundleName)$(AppBundleExtension)">
<Codesign
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' And '$(IsAppExtension)' == 'false'"
Condition="'$(IsMacEnabled)' == 'true'"
ToolExe="$(CodesignExe)"
ToolPath="$(CodesignPath)"
CodesignAllocate="$(_CodesignAllocate)"
Expand All @@ -1718,14 +1761,35 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
>
</Codesign>

<MakeDir SessionId="$(BuildSessionId)" Condition="'$(IsMacEnabled)' == 'true'" Directories="$(DeviceSpecificIntermediateOutputPath)codesign" />

<Touch
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
AlwaysCreate="true"
Files="$(DeviceSpecificIntermediateOutputPath)codesign\$(_AppBundleName)$(AppBundleExtension)"
>
<Output TaskParameter="TouchedFiles" ItemName="FileWrites" />
</Touch>

<Touch
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' And '$(_RequireCodeSigning)' == 'true' And '$(IsAppExtension)' == 'false' And Exists ('$(AppBundleDir).dSYM\Contents\Info.plist')"
Condition="'$(IsMacEnabled)' == 'true' And Exists ('$(AppBundleDir).dSYM\Contents\Info.plist')"
Files="$(AppBundleDir).dSYM\Contents\Info.plist"
/>
</Target>

<Target Name="_CodesignVerify" Condition="'$(_RequireCodeSigning)' == 'true' And '$(IsAppExtension)' == 'false'" DependsOnTargets="_CodesignAppBundle">
<CodesignVerify
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' And '@(_AppExtensionCodesignProperties)' != ''"
ToolExe="$(CodesignExe)"
ToolPath="$(CodesignPath)"
CodesignAllocate="$(_CodesignAllocate)"
Resource="$(_AppBundlePath)PlugIns\%(_AppExtensionCodesignProperties.Identity)"
>
</CodesignVerify>

<CodesignVerify
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override void Setup ()
SetupEngine ();
}

public void BuildProject (string appName, string platform, string config, int expectedErrorCount = 0)
public void BuildProject (string appName, string platform, string config, int expectedErrorCount = 0, bool clean = true)
{
var mtouchPaths = SetupProjectPaths (appName, "../", true, platform, config);

Expand All @@ -43,8 +43,10 @@ public void BuildProject (string appName, string platform, string config, int ex
Engine.GlobalProperties.SetProperty("Platform", platform);
Engine.GlobalProperties.SetProperty("Configuration", config);

RunTarget (proj, "Clean");
Assert.IsFalse (Directory.Exists (AppBundlePath), "App bundle exists after cleanup: {0} ", AppBundlePath);
if (clean) {
RunTarget (proj, "Clean");
Assert.IsFalse (Directory.Exists (AppBundlePath), "App bundle exists after cleanup: {0} ", AppBundlePath);
}

proj = SetupProject (Engine, mtouchPaths.ProjectCSProjPath);
RunTarget (proj, "Build", expectedErrorCount);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
using NUnit.Framework;
using System.IO;
using System.Linq;
using System.Threading;

using NUnit.Framework;

namespace Xamarin.iOS.Tasks
{
Expand All @@ -14,5 +18,29 @@ public void BuildTest ()
{
BuildProject ("MyReleaseBuild", Platform, "Release");
}

[Test]
public void RebuildTest ()
{
BuildProject ("MyReleaseBuild", Platform, "Release", clean: true);

var dsymDir = Path.GetFullPath (Path.Combine (AppBundlePath, "..", Path.GetFileName (AppBundlePath) + ".dSYM"));

var timestamps = Directory.EnumerateFiles (AppBundlePath, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file));
var dsymTimestamps = Directory.EnumerateFiles (dsymDir, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file));

Thread.Sleep (1000);

BuildProject ("MyReleaseBuild", Platform, "Release", clean: false);

var newTimestamps = Directory.EnumerateFiles (AppBundlePath, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file));
var newDSymTimestamps = Directory.EnumerateFiles (dsymDir, "*.*", SearchOption.AllDirectories).ToDictionary (file => file, file => GetLastModified (file));

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

foreach (var file in dsymTimestamps.Keys)
Assert.AreEqual (dsymTimestamps[file], newDSymTimestamps[file], "#2: " + file);
}
}
}