[msbuild] Change the logic about how the prebuilt app bundle is decompressed.
1. Compute the path of the zip in the .props file, and use it as Inputs for the PrepareAppBundle target. This way we only run PrepareAppBundle if the zip file has changed (and we actually run it if it has changed). 2. Delete any previous unzipped contents if we're unzipping (to make sure we don't have files leftover from an earlier version of the prebuilt zip). 3. Compute the 'HotRestartAppBundlePath' in a new and earlier task. This means we can also depend on this targe in the _CleanHotRestartBundle target to avoid having to compute the 'HotRestartAppBundlePath' property there as well. 4. Move the touching of the stamp file (the 'Extracted' file) to MSBuild. This way it shows up in logs. 5. Enable nullability in the PrepareAppBundle target and fix any issues.
This commit is contained in:
Родитель
6c4dbf89a6
Коммит
2074b5e327
|
@ -5,25 +5,29 @@ using System.IO.Compression;
|
|||
using Xamarin.iOS.Windows;
|
||||
using Xamarin.MacDev;
|
||||
|
||||
#nullable enable
|
||||
|
||||
namespace Xamarin.iOS.HotRestart.Tasks {
|
||||
public class PrepareAppBundle : Task {
|
||||
#region Inputs
|
||||
|
||||
[Required]
|
||||
public string AppBundleName { get; set; }
|
||||
public string AppBundleName { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public string SessionId { get; set; }
|
||||
public string SessionId { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
public bool ShouldExtract { get; set; }
|
||||
|
||||
public string PreBuiltAppBundlePath { get; set; } = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Outputs
|
||||
|
||||
[Output]
|
||||
public string AppBundlePath { get; set; }
|
||||
public string AppBundlePath { get; set; } = string.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -32,17 +36,14 @@ namespace Xamarin.iOS.HotRestart.Tasks {
|
|||
if (string.IsNullOrEmpty (AppBundlePath))
|
||||
AppBundlePath = HotRestartContext.Default.GetAppBundlePath (AppBundleName, SessionId.Substring (0, 8));
|
||||
|
||||
if (!Directory.Exists (AppBundlePath) && ShouldExtract) {
|
||||
var preBuiltAppBundlePath = Path.Combine (
|
||||
Path.GetDirectoryName (typeof (PrepareAppBundle).Assembly.Location),
|
||||
"Xamarin.PreBuilt.iOS.app.zip");
|
||||
if (ShouldExtract) {
|
||||
Directory.Delete (AppBundlePath, true);
|
||||
|
||||
ZipFile.ExtractToDirectory (preBuiltAppBundlePath, AppBundlePath);
|
||||
Log.LogMessage (MessageImportance.Low, $"Extracting '{PreBuiltAppBundlePath}' into {AppBundlePath}.");
|
||||
ZipFile.ExtractToDirectory (PreBuiltAppBundlePath, AppBundlePath);
|
||||
|
||||
// Ensure the archived-expanded-entitlements.xcent is empty. If there are any entitlements in that file, the new signature will be invalid
|
||||
new PDictionary ().Save (Path.Combine (AppBundlePath, "archived-expanded-entitlements.xcent"));
|
||||
|
||||
File.WriteAllText (Path.Combine (AppBundlePath, "Extracted"), string.Empty);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
@ -13,5 +13,7 @@
|
|||
<HotRestartIPAPath>$(HotRestartSignedAppOutputDir)$(_AppBundleName).ipa</HotRestartIPAPath>
|
||||
|
||||
<UnpackHotRestartFrameworks Condition="'$(UnpackHotRestartFrameworks)' == ''">true</UnpackHotRestartFrameworks>
|
||||
|
||||
<HotRestartPreBuiltZipPath Condition="'$(HotRestartPreBuiltZipPath)' == ''">$(MSBuildThisFileDirectory)Xamarin.PreBuilt.iOS.app.zip</HotRestartPreBuiltZipPath>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
|
|
@ -75,19 +75,39 @@
|
|||
|
||||
<Target Name="_CreateHotRestartCachedBundle" DependsOnTargets="$(_CreateHotRestartCachedBundleDependsOn)" />
|
||||
|
||||
<Target Name="_ComputeHotRestartAppBundlePath"
|
||||
DependsOnTargets="_GenerateHotRestartBuildSessionId"
|
||||
Condition="'$(IsHotRestartBuild)' == 'true' And '$(HotRestartAppBundlePath)' == ''"
|
||||
>
|
||||
|
||||
<PrepareAppBundle
|
||||
Condition="'$(IsHotRestartBuild)' == 'true'"
|
||||
AppBundleName="$(_AppBundleName)"
|
||||
SessionId="$(HotRestartBuildSessionId)"
|
||||
ShouldExtract="false"
|
||||
>
|
||||
|
||||
<Output TaskParameter="AppBundlePath" PropertyName="HotRestartAppBundlePath" />
|
||||
</PrepareAppBundle>
|
||||
</Target>
|
||||
|
||||
<!-- Creates HotRestart app bundle -->
|
||||
<Target Name="_PrepareHotRestartAppBundle" DependsOnTargets="_GenerateHotRestartBuildSessionId"
|
||||
Condition="'$(_CanOutputAppBundle)' == 'true' And '$(IsAppExtension)' == 'false' And '$(IsHotRestartBuild)' == 'true'">
|
||||
<Target Name="_PrepareHotRestartAppBundle"
|
||||
DependsOnTargets="_GenerateHotRestartBuildSessionId;_ComputeHotRestartAppBundlePath"
|
||||
Condition="'$(_CanOutputAppBundle)' == 'true' And '$(IsAppExtension)' == 'false' And '$(IsHotRestartBuild)' == 'true'"
|
||||
Inputs="$(HotRestartPreBuiltZipPath)"
|
||||
Outputs="$(HotRestartAppBundlePath)\Extracted"
|
||||
>
|
||||
|
||||
<!--Create app bundle dir and get its path-->
|
||||
<PrepareAppBundle
|
||||
AppBundleName="$(_AppBundleName)"
|
||||
AppBundlePath="$(HotRestartAppBundlePath)"
|
||||
PreBuiltAppBundlePath="$(HotRestartPreBuiltZipPath)"
|
||||
SessionId="$(HotRestartBuildSessionId)"
|
||||
ShouldExtract="true">
|
||||
ShouldExtract="true" />
|
||||
|
||||
<Output TaskParameter="AppBundlePath" PropertyName="HotRestartAppBundlePath" />
|
||||
</PrepareAppBundle>
|
||||
<Touch AlwaysCreate="true" Files="$(HotRestartAppBundlePath)\Extracted" />
|
||||
|
||||
<!-- Delete the build signature to force XMA do a full build next time -->
|
||||
<Delete Files="$(BuildSignatureFile)" Condition="Exists('$(BuildSignatureFile)')" />
|
||||
|
@ -243,17 +263,7 @@
|
|||
</CleanDependsOn>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="_CleanHotRestartBundle" DependsOnTargets="_GenerateHotRestartBuildSessionId" >
|
||||
<!-- Gets the bundle path -->
|
||||
<PrepareAppBundle
|
||||
Condition="'$(IsHotRestartBuild)' == 'true'"
|
||||
AppBundleName="$(_AppBundleName)"
|
||||
SessionId="$(HotRestartBuildSessionId)"
|
||||
ShouldExtract="false">
|
||||
|
||||
<Output TaskParameter="AppBundlePath" PropertyName="HotRestartAppBundlePath" />
|
||||
</PrepareAppBundle>
|
||||
|
||||
<Target Name="_CleanHotRestartBundle" DependsOnTargets="_GenerateHotRestartBuildSessionId;_ComputeHotRestartAppBundlePath" >
|
||||
<RemoveDir Directories="$(HotRestartAppBundlePath)" />
|
||||
<RemoveDir Directories="$(HotRestartSignedAppOutputDir)" />
|
||||
<RemoveDir Directories="$(DeviceSpecificIntermediateOutputPath)UnpackedFrameworks" />
|
||||
|
|
Загрузка…
Ссылка в новой задаче