Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release/8.0.1xx] [msbuild] Copy files to be signed into the correct directory for Hot Restart. Fixes #19278. #19335

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 @@ -25,7 +25,7 @@ public class ComputeHotRestartBundleContents : Task {
public string HotRestartContentStampDir { get; set; } = string.Empty;

[Required]
public string HotRestartSignedAppDir { get; set; } = string.Empty;
public string HotRestartAppBundlePath { get; set; } = string.Empty;

[Required]
public string RelativeAppBundlePath { get; set; } = string.Empty;
Expand All @@ -47,7 +47,7 @@ public class ComputeHotRestartBundleContents : Task {
public ITaskItem [] HotRestartContentDirContents { get; set; } = Array.Empty<ITaskItem> ();

[Output]
public ITaskItem [] HotRestartSignedAppDirContents { get; set; } = Array.Empty<ITaskItem> ();
public ITaskItem [] HotRestartAppBundleContents { get; set; } = Array.Empty<ITaskItem> ();

#endregion

Expand Down Expand Up @@ -108,7 +108,7 @@ public override bool Execute ()
{
var appContentDirContents = new List<ITaskItem> ();
var contentDirContents = new List<ITaskItem> ();
var signedAppDirContents = new List<ITaskItem> ();
var appBundleContents = new List<ITaskItem> ();

foreach (var item in ResolvedFileToPublish) {
var publishFolderType = item.GetPublishFolderType ();
Expand All @@ -126,13 +126,13 @@ public override bool Execute ()
if (string.Equals (filename + ".framework", dirname, StringComparison.OrdinalIgnoreCase))
item.ItemSpec = Path.GetDirectoryName (item.ItemSpec);
// These have to be signed
signedAppDirContents.Add (CopyWithDestinationAndStamp (item, HotRestartSignedAppDir));
appBundleContents.Add (CopyWithDestinationAndStamp (item, HotRestartAppBundlePath));
break;
case PublishFolderType.PlugIns:
case PublishFolderType.DynamicLibrary:
case PublishFolderType.PluginLibrary:
// These have to be signed
signedAppDirContents.Add (CopyWithDestinationAndStamp (item, HotRestartSignedAppDir));
appBundleContents.Add (CopyWithDestinationAndStamp (item, HotRestartAppBundlePath));
break;

case PublishFolderType.Unset: // Don't copy unknown stuff anywhere
Expand All @@ -155,11 +155,11 @@ public override bool Execute ()

appContentDirContents = ExpandDirectories (appContentDirContents);
contentDirContents = ExpandDirectories (contentDirContents);
signedAppDirContents = ExpandDirectories (signedAppDirContents);
appBundleContents = ExpandDirectories (appBundleContents);

HotRestartAppContentDirContents = appContentDirContents.ToArray ();
HotRestartContentDirContents = contentDirContents.ToArray ();
HotRestartSignedAppDirContents = signedAppDirContents.ToArray ();
HotRestartAppBundleContents = appBundleContents.ToArray ();

return !Log.HasLoggedErrors;
}
Expand Down
35 changes: 35 additions & 0 deletions msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.HotRestart.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,46 @@
<!-- Use single-project MSBuild properties to generate the application manifest by default -->
<GenerateApplicationManifest Condition="'$(GenerateApplicationManifest)' == ''">true</GenerateApplicationManifest>

<!-- HotRestartAppBundlePath: the app bundle that will be signed. Any files that must be signed or present at app startup must be in this directory before the _CodesignHotRestartAppBundle target -->
<!-- This property is calculated in the _ComputeHotRestartAppBundlePath target -->

<!-- HotRestartSignedAppOutputDir: the main location of all the final files. It contains the Payload dir + the contents dir used for incremental deployments. -->
<HotRestartSignedAppOutputDir Condition="'$(HotRestartSignedAppOutputDir)' == ''">$(TEMP)\Xamarin\HotRestart\Signing\$(_AppBundleName)$(AppBundleExtension)\out\</HotRestartSignedAppOutputDir>

<!-- HotRestartPayloadDir: it essentially contains the final signed app bundle, that we then zip it to create an IPA file. The app bundle in this folder is the result of re-signing the one in HotRestartAppBundlePath + adding the .contents dir. -->
<HotRestartPayloadDir>$(HotRestartSignedAppOutputDir)Payload\</HotRestartPayloadDir>

<!--

This is the location of the signed app bundle.

Nothing should be put in this directory directly by the targets, because:
1. This directory will be cleared before signing (the _PrepareHotRestartAppBundle target);
anything in this directory before this point will be deleted.
2. After signing, it shouldn't change (because that would invalidate the signature).

-->
<HotRestartSignedAppDir>$(HotRestartPayloadDir)$(_AppBundleName).app\</HotRestartSignedAppDir>
<!--

HotRestartContentDir and HotRestartAppContentDir:

These two are virtually the same but used for different purposes.
The Content dir contains the files that don't need to be shipped
in the root of the app bundle, and don't need to be signed. This
files can then be pushed to the app individually without needing
to redeploy the app, making things much faster. This usually
contains assemblies, like the app project one.
HotRestartAppContentDir is the location of the Content dir inside
the signed app bundle (in case we need to re-deploy the whole
app). HotRestartContentDir has the same content with some stamp
files to detect which file can be incrementally pushed to the app
(in case we don't need to re-deploy the app)

-->
<HotRestartContentDir>$(HotRestartSignedAppOutputDir)$(_AppBundleName).content\</HotRestartContentDir>
<HotRestartAppContentDir>$(HotRestartSignedAppDir)$(_AppBundleName).content\</HotRestartAppContentDir>

<HotRestartContentStampDir>$(HotRestartSignedAppOutputDir)$(_AppBundleName).stamp\</HotRestartContentStampDir>
<HotRestartIPAPath>$(HotRestartSignedAppOutputDir)$(_AppBundleName).ipa</HotRestartIPAPath>

Expand Down
22 changes: 11 additions & 11 deletions msbuild/Xamarin.iOS.Tasks.Windows/Xamarin.iOS.HotRestart.targets
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@
HotRestartAppContentDir="$(HotRestartAppContentDir)"
HotRestartContentDir="$(HotRestartContentDir)"
HotRestartContentStampDir="$(HotRestartContentStampDir)"
HotRestartSignedAppDir="$(HotRestartSignedAppDir)"
HotRestartAppBundlePath="$(HotRestartAppBundlePath)"
RelativeAppBundlePath="$(_RelativeAppBundlePath)"
ResolvedFileToPublish="@(ResolvedFileToPublish);@(_FileNativeReference);@(_FrameworkNativeReference);@(_DecompressedPlugIns);@(_PlugIns)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
>
<Output TaskParameter="HotRestartAppContentDirContents" ItemName="_HotRestartAppContentDirContents" />
<Output TaskParameter="HotRestartContentDirContents" ItemName="_HotRestartContentDirContents" />
<Output TaskParameter="HotRestartSignedAppDirContents" ItemName="_HotRestartSignedAppDirContents" />
<Output TaskParameter="HotRestartAppBundleContents" ItemName="_HotRestartAppBundleDirContents" />
</ComputeHotRestartBundleContents>
</Target>

Expand Down Expand Up @@ -153,27 +153,27 @@
Condition="'$(_CanOutputAppBundle)' == 'true' And '$(IsAppExtension)' == 'false' And '$(IsHotRestartBuild)' == 'true'"
DependsOnTargets="_CreateHotRestartCachedBundle;_UnpackLibraryResources"
Inputs="@(_BundleResourceWithLogicalName)"
Outputs="@(_BundleResourceWithLogicalName -> '$(HotRestartSignedAppDir)%(LogicalName)')">
Outputs="@(_BundleResourceWithLogicalName -> '$(HotRestartAppBundlePath)\%(LogicalName)')">

<Copy
SourceFiles="@(_BundleResourceWithLogicalName)"
DestinationFiles="@(_BundleResourceWithLogicalName -> '$(HotRestartSignedAppDir)%(LogicalName)')"
DestinationFiles="@(_BundleResourceWithLogicalName -> '$(HotRestartAppBundlePath)\%(LogicalName)')"
SkipUnchangedFiles="true"
>
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
</Copy>
</Target>

<!-- Copy the items in _HotRestartSignedAppDirContents to their destination directory -->
<!-- Copy the items in _HotRestartAppBundleDirContents to their destination directory -->
<Target Name="_CopyFilesToHotRestartSignedAppDirContents"
Condition="'$(_CanOutputAppBundle)' == 'true' And '$(IsAppExtension)' == 'false' And '$(IsHotRestartBuild)' == 'true'"
DependsOnTargets="_CreateHotRestartCachedBundle;_ComputeHotRestartBundleContents"
Inputs="@(_HotRestartSignedAppDirContents)"
Outputs="@(_HotRestartSignedAppDirContents -> '%(DestinationFile)')">
Inputs="@(_HotRestartAppBundleDirContents)"
Outputs="@(_HotRestartAppBundleDirContents -> '%(DestinationFile)')">

<Copy
SourceFiles="@(_HotRestartSignedAppDirContents)"
DestinationFiles="@(_HotRestartSignedAppDirContents -> '%(DestinationFile)')"
SourceFiles="@(_HotRestartAppBundleDirContents)"
DestinationFiles="@(_HotRestartAppBundleDirContents -> '%(DestinationFile)')"
SkipUnchangedFiles="true"
>
<Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
Expand Down Expand Up @@ -236,7 +236,7 @@
<_CodeSignHotRestartInputs Include="$(_AppBundleManifestPath)" Outputs="$(HotRestartSignedAppDir)Info.plist" />
<_CodeSignHotRestartInputs Include="$(CodesignEntitlements)" Outputs="$(HotRestartSignedAppDir)$(CodesignEntitlements)" />
<_CodeSignHotRestartInputs Include="$(_ProvisioningProfilePath)" Outputs="$(HotRestartSignedAppDir)embedded.mobileprovision" />
<_CodeSignHotRestartInputs Include="@(_HotRestartSignedAppDirContents)" Outputs="%(_HotRestartSignedAppDirContents.DestinationFile)" />
<_CodeSignHotRestartInputs Include="@(_HotRestartAppBundleDirContents)" Outputs="%(_HotRestartAppBundleDirContents.DestinationFile)" />
<_CodeSignHotRestartInputs Include="$(HotRestartAppBundlePath)\Extracted" Outputs="$(HotRestartSignedAppDir)Extracted" />
</ItemGroup>
</Target>
Expand All @@ -246,9 +246,9 @@
_CreateHotRestartCachedBundle;
_UnpackLibraryResources;
_ComputeHotRestartBundleContents;
_CodesignHotRestartAppBundle;
_CopyHotRestartBundleResources;
_CopyFilesToHotRestartSignedAppDirContents;
_CodesignHotRestartAppBundle;
_CopyFilesToHotRestartContentDir;
_CopyFilesToHotRestartAppContentDir;
_CreateHotRestartAppMarkers;
Expand Down