[msbuild] Added EnableOnDemandResources option (#2133)
* [msbuild] Added EnableOnDemandResources option Disabling this option causes the ACTool task to pass --enable-on-demand-resources NO (instead of YES) to actool. It will also cause the ResourceTags property on BundleResource and InterfaceBuilder items to be ignored. * Fixed unit tests
This commit is contained in:
Родитель
a69c85bae7
Коммит
7facec2a70
|
@ -563,6 +563,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
|
|||
ToolExe="$(ACToolExe)"
|
||||
ToolPath="$(ACToolPath)"
|
||||
AppManifest="$(_AppManifest)"
|
||||
EnableOnDemandResources="false"
|
||||
ImageAssets="@(ImageAsset)"
|
||||
OptimizePngs="false"
|
||||
OutputPath="$(OutputPath)"
|
||||
|
@ -611,6 +612,7 @@ Copyright (C) 2014 Xamarin. All rights reserved.
|
|||
ToolExe="$(IBToolExe)"
|
||||
ToolPath="$(IBToolPath)"
|
||||
AppManifest="$(_AppManifest)"
|
||||
EnableOnDemandResources="false"
|
||||
InterfaceDefinitions="@(InterfaceDefinition)"
|
||||
IntermediateOutputPath="$(IntermediateOutputPath)"
|
||||
SdkPlatform="MacOSX"
|
||||
|
|
|
@ -26,6 +26,8 @@ namespace Xamarin.MacDev.Tasks
|
|||
|
||||
public string DeviceOSVersion { get; set; }
|
||||
|
||||
public bool EnableOnDemandResources { get; set; }
|
||||
|
||||
[Required]
|
||||
public ITaskItem[] ImageAssets { get; set; }
|
||||
|
||||
|
@ -156,7 +158,7 @@ namespace Xamarin.MacDev.Tasks
|
|||
|
||||
if (AppleSdkSettings.XcodeVersion.Major >= 7) {
|
||||
if (!string.IsNullOrEmpty (outputSpecs))
|
||||
args.Add ("--enable-on-demand-resources", "YES");
|
||||
args.Add ("--enable-on-demand-resources", EnableOnDemandResources ? "YES" : "NO");
|
||||
|
||||
if (!string.IsNullOrEmpty (DeviceModel))
|
||||
args.Add ("--filter-for-device-model", DeviceModel);
|
||||
|
@ -258,6 +260,7 @@ namespace Xamarin.MacDev.Tasks
|
|||
Log.LogTaskProperty ("AppManifest", AppManifest);
|
||||
Log.LogTaskProperty ("DeviceModel", DeviceModel);
|
||||
Log.LogTaskProperty ("DeviceOSVersion", DeviceOSVersion);
|
||||
Log.LogTaskProperty ("EnableOnDemandResources", EnableOnDemandResources);
|
||||
Log.LogTaskProperty ("ImageAssets", ImageAssets);
|
||||
Log.LogTaskProperty ("IntermediateOutputPath", IntermediateOutputPath);
|
||||
Log.LogTaskProperty ("IsWatchApp", IsWatchApp);
|
||||
|
|
|
@ -21,6 +21,8 @@ namespace Xamarin.MacDev.Tasks
|
|||
|
||||
public ITaskItem[] BundleResources { get; set; }
|
||||
|
||||
public bool EnableOnDemandResources { get; set; }
|
||||
|
||||
[Required]
|
||||
public string IntermediateOutputPath { get; set; }
|
||||
|
||||
|
@ -36,6 +38,7 @@ namespace Xamarin.MacDev.Tasks
|
|||
Log.LogTaskProperty ("AppBundleDir", AppBundleDir);
|
||||
Log.LogTaskProperty ("BundleIdentifier", BundleIdentifier);
|
||||
Log.LogTaskProperty ("BundleResources", BundleResources);
|
||||
Log.LogTaskProperty ("EnableOnDemandResources", EnableOnDemandResources);
|
||||
Log.LogTaskProperty ("IntermediateOutputPath", IntermediateOutputPath);
|
||||
Log.LogTaskProperty ("OutputPath", OutputPath);
|
||||
|
||||
|
@ -47,10 +50,10 @@ namespace Xamarin.MacDev.Tasks
|
|||
foreach (var item in BundleResources) {
|
||||
var logicalName = item.GetMetadata ("LogicalName");
|
||||
var outputPath = item.GetMetadata ("OutputPath");
|
||||
var tags = AssetPackUtils.GetResourceTags (item);
|
||||
IList<string> tags;
|
||||
string hash;
|
||||
|
||||
if (tags != null) {
|
||||
if (EnableOnDemandResources && (tags = AssetPackUtils.GetResourceTags (item)) != null) {
|
||||
var assetpack = AssetPackUtils.GetAssetPackDirectory (OutputPath, BundleIdentifier, tags, out hash);
|
||||
|
||||
if (packs.Add (hash)) {
|
||||
|
|
|
@ -17,6 +17,8 @@ namespace Xamarin.MacDev.Tasks
|
|||
|
||||
#region Inputs
|
||||
|
||||
public bool EnableOnDemandResources { get; set; }
|
||||
|
||||
[Required]
|
||||
public ITaskItem[] InterfaceDefinitions { get; set; }
|
||||
|
||||
|
@ -208,7 +210,7 @@ namespace Xamarin.MacDev.Tasks
|
|||
expected.SetMetadata ("LogicalName", bundleName);
|
||||
expected.SetMetadata ("Optimize", "false");
|
||||
|
||||
if (!string.IsNullOrEmpty (resourceTags))
|
||||
if (EnableOnDemandResources && !string.IsNullOrEmpty (resourceTags))
|
||||
expected.SetMetadata ("ResourceTags", resourceTags);
|
||||
|
||||
if (UseCompilationDirectory) {
|
||||
|
@ -398,6 +400,7 @@ namespace Xamarin.MacDev.Tasks
|
|||
{
|
||||
Log.LogTaskName ("IBTool");
|
||||
Log.LogTaskProperty ("AppManifest", AppManifest);
|
||||
Log.LogTaskProperty ("EnableOnDemandResources", EnableOnDemandResources);
|
||||
Log.LogTaskProperty ("InterfaceDefinitions", InterfaceDefinitions);
|
||||
Log.LogTaskProperty ("IntermediateOutputPath", IntermediateOutputPath);
|
||||
Log.LogTaskProperty ("IsWatchApp", IsWatchApp);
|
||||
|
|
|
@ -85,8 +85,9 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
|
|||
<MtouchArch Condition="'$(MtouchArch)' == '' And '$(_Platform)' == 'iPhone'">ARMv7</MtouchArch>
|
||||
|
||||
<!-- On-Demand Resources -->
|
||||
<OnDemandResourcesInitialInstallTags Condition="'$(OnDemandResourcesInitialInstallTags)' == ''"></OnDemandResourcesInitialInstallTags>
|
||||
<OnDemandResourcesPrefetchOrder Condition="'$(OnDemandResourcesPrefetchOrder)' == ''"></OnDemandResourcesPrefetchOrder>
|
||||
<EnableOnDemandResources Condition="'$(EnableOnDemandResources)' == ''">true</EnableOnDemandResources>
|
||||
<OnDemandResourcesInitialInstallTags Condition="'$(OnDemandResourcesInitialInstallTags)' == '' Or '$(EnableOnDemandResources)' != 'true'"></OnDemandResourcesInitialInstallTags>
|
||||
<OnDemandResourcesPrefetchOrder Condition="'$(OnDemandResourcesPrefetchOrder)' == '' Or '$(EnableOnDemandResources)' != 'true'"></OnDemandResourcesPrefetchOrder>
|
||||
<EmbedOnDemandResources Condition="'$(EmbedOnDemandResources)' == ''">true</EmbedOnDemandResources>
|
||||
|
||||
<!-- Device-Specific Builds -->
|
||||
|
|
|
@ -438,6 +438,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
|
|||
AppBundleDir="$(AppBundleDir)"
|
||||
BundleIdentifier="$(_BundleIdentifier)"
|
||||
BundleResources="@(_BundleResourceWithLogicalName)"
|
||||
EnableOnDemandResources="$(EnableOnDemandResources)"
|
||||
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
|
||||
OutputPath="$(DeviceSpecificOutputPath)"
|
||||
>
|
||||
|
@ -1172,6 +1173,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
|
|||
AppManifest="$(_AppManifest)"
|
||||
DeviceModel="$(TargetDeviceModel)"
|
||||
DeviceOSVersion="$(TargetDeviceOSVersion)"
|
||||
EnableOnDemandResources="$(EnableOnDemandResources)"
|
||||
ImageAssets="@(ImageAsset)"
|
||||
OptimizePNGs="$(OptimizePNGs)"
|
||||
OutputPath="$(DeviceSpecificOutputPath)"
|
||||
|
@ -1282,6 +1284,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
|
|||
ToolExe="$(IBToolExe)"
|
||||
ToolPath="$(IBToolPath)"
|
||||
AppManifest="$(_AppManifest)"
|
||||
EnableOnDemandResources="$(EnableOnDemandResources)"
|
||||
InterfaceDefinitions="@(InterfaceDefinition)"
|
||||
IntermediateOutputPath="$(DeviceSpecificIntermediateOutputPath)"
|
||||
IsWatchApp="$(IsWatchApp)"
|
||||
|
@ -1969,7 +1972,7 @@ Copyright (C) 2013-2016 Xamarin. All rights reserved.
|
|||
</PropertyGroup>
|
||||
</Target>
|
||||
|
||||
<Target Name="_PackageOnDemandResources" Condition="'$(BuildIpa)' == 'true' And ('$(_DistributionType)' == 'AppStore' Or '$(_DistributionType)' == 'AdHoc')" >
|
||||
<Target Name="_PackageOnDemandResources" Condition="'$(BuildIpa)' == 'true' And '$(EnableOnDemandResources)' == 'true' And ('$(_DistributionType)' == 'AppStore' Or '$(_DistributionType)' == 'AdHoc')" >
|
||||
<PropertyGroup>
|
||||
<_PayloadDir>$(DeviceSpecificIntermediateOutputPath)ipa\Payload\</_PayloadDir>
|
||||
<_IpaAppBundleDir>$(_PayloadDir)$(_AppBundleName).app\</_IpaAppBundleDir>
|
||||
|
|
|
@ -125,6 +125,8 @@ namespace Xamarin.iOS.Tasks
|
|||
storyboard.SetMetadata ("ResourceTags", tag);
|
||||
}
|
||||
|
||||
ibtool.EnableOnDemandResources = true;
|
||||
|
||||
Assert.IsTrue (ibtool.Execute (), "Execution of IBTool task failed.");
|
||||
|
||||
foreach (var bundleResource in ibtool.BundleResources) {
|
||||
|
@ -141,6 +143,8 @@ namespace Xamarin.iOS.Tasks
|
|||
bundleResources.Add (bundleName);
|
||||
}
|
||||
|
||||
ibtool.EnableOnDemandResources = true;
|
||||
|
||||
string[] expected = {
|
||||
"Base.lproj/LaunchScreen.storyboardc/01J-lp-oVM-view-Ze5-6b-2t3.nib",
|
||||
"Base.lproj/LaunchScreen.storyboardc/Info.plist",
|
||||
|
@ -200,6 +204,8 @@ namespace Xamarin.iOS.Tasks
|
|||
storyboard.SetMetadata ("ResourceTags", tag);
|
||||
}
|
||||
|
||||
ibtool.EnableOnDemandResources = true;
|
||||
|
||||
Assert.IsTrue (ibtool.Execute (), "Execution of IBTool task failed.");
|
||||
|
||||
foreach (var bundleResource in ibtool.BundleResources) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче