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
4 changes: 2 additions & 2 deletions msbuild/Xamarin.MacDev.Tasks/Tasks/CompileAppManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ public override bool Execute ()
Validation (plist);

// write the resulting app manifest
if (FileUtils.UpdateFile (CompiledAppManifest!.ItemSpec, (tmpfile) => plist.Save (tmpfile, true, true)))
Log.LogMessage (MessageImportance.Low, "The file {0} is up-to-date.", CompiledAppManifest.ItemSpec);
plist.Save (CompiledAppManifest!.ItemSpec, true, true);
Log.LogMessage (MessageImportance.Low, "The app manifest {0} was updated.", CompiledAppManifest.ItemSpec);

return !Log.HasLoggedErrors;
}
Expand Down
77 changes: 67 additions & 10 deletions msbuild/Xamarin.Shared/Xamarin.Shared.targets
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
<PropertyGroup>
<_CompileAppManifestDependsOn>
CollectAppManifests;
_CompileAppManifestInputs;
$(_CompileAppManifestDependsOn);
_DetectBuildType;
_DetectAppManifest;
Expand All @@ -595,29 +596,86 @@ Copyright (C) 2018 Microsoft. All rights reserved.
to the CollectAppManifestsDependsOn property. -->
<Target Name="CollectAppManifests" DependsOnTargets="$(CollectAppManifestsDependsOn)" />

<!-- This target has no inputs, because it must still be run if there are no input app manifests, to set default values -->
<Target Name="_CompileAppManifestInputs"
Condition="'$(IsMacEnabled)' == 'true' Or '$(IsHotRestartBuild)' == 'true'"
>
<ItemGroup>
<_FontFilesToRegister Include="@(BundleResource)" Condition="'%(BundleResource.RegisterFont)' == 'true'" />
</ItemGroup>

<PropertyGroup>
<_CompileAppManifestInputFile>$(DeviceSpecificIntermediateOutputPath)_CompileAppManifest.inputs</_CompileAppManifestInputFile>
<_CompileAppManifestFontFilesToRegister>@(_FontFilesToRegister)</_CompileAppManifestFontFilesToRegister>
<_CompileAppManifestPartialAppManifest>@(PartialAppManifest)</_CompileAppManifestPartialAppManifest>
</PropertyGroup>
<ItemGroup>
<!-- @(_CompileAppManifestInputLine) are lines to write in $(_CompileAppManifestInputFile) -->
<_CompileAppManifestInputLine Include="AppBundleName=$(_AppBundleName)" />
<_CompileAppManifestInputLine Include="ApplicationDisplayVersion=$(ApplicationDisplayVersion)" />
<_CompileAppManifestInputLine Include="ApplicationId=$(ApplicationId)" />
<_CompileAppManifestInputLine Include="ApplicationTitle=$(ApplicationTitle)" />
<_CompileAppManifestInputLine Include="ApplicationVersion=$(ApplicationVersion)" />
<_CompileAppManifestInputLine Include="AppManifest=$(AppBundleManifest)" />
<_CompileAppManifestInputLine Include="AssemblyName=$(AssemblyName)" />
<_CompileAppManifestInputLine Include="CompiledAppManifest=$(_TemporaryAppManifest)" />
<_CompileAppManifestInputLine Include="Debug=$(_BundlerDebug)" />
<_CompileAppManifestInputLine Include="DebugIPAddresses=$(_DebugIPAddresses)" />
<_CompileAppManifestInputLine Include="DefaultSdkVersion=$(_SdkVersion)" />
<_CompileAppManifestInputLine Include="FontFilesToRegister=$(_CompileAppManifestFontFilesToRegister)" />
<_CompileAppManifestInputLine Include="GenerateApplicationManifest=$(GenerateApplicationManifest)" />
<_CompileAppManifestInputLine Include="IsAppExtension=$(IsAppExtension)" />
<_CompileAppManifestInputLine Include="IsWatchApp=$(IsWatchApp)" />
<_CompileAppManifestInputLine Include="IsWatchExtension=$(IsWatchExtension)" />
<_CompileAppManifestInputLine Include="IsXPCService=$(IsXPCService)" />
<_CompileAppManifestInputLine Include="MinSupportedOSPlatformVersion=$(MinSupportedOSPlatformVersion)" />
<_CompileAppManifestInputLine Include="PartialAppManifests=$(_CompileAppManifestPartialAppManifest)" />
<_CompileAppManifestInputLine Include="ProjectDir=$(MSBuildProjectDirectory)" />
<_CompileAppManifestInputLine Include="ResourcePrefix=$(_ResourcePrefix)" />
<_CompileAppManifestInputLine Include="ResourceRules=$(_PreparedResourceRules)" />
<_CompileAppManifestInputLine Include="SdkIsSimulator=$(_SdkIsSimulator)" />
<_CompileAppManifestInputLine Include="SdkVersion=$(_SdkVersion)" />
<_CompileAppManifestInputLine Include="SupportedOSPlatformVersion=$(SupportedOSPlatformVersion)" />
<_CompileAppManifestInputLine Include="TargetArchitectures=$(TargetArchitectures)" />
<_CompileAppManifestInputLine Include="TargetFrameworkMoniker=$(_ComputedTargetFrameworkMoniker)" />
<_CompileAppManifestInputLine Include="Validate=$(_CreateAppManifest)" />
<!-- @(_CompileAppManifestInputFile) contains additional files to use as Inputs -->
<_CompileAppManifestInputFile Include="$(_CompileAppManifestInputFile)" />
<_CompileAppManifestInputFile Include="@(_FontFilesToRegister)" />
<_CompileAppManifestInputFile Include="@(PartialAppManifest)" />
</ItemGroup>
<!-- If any of the above values change, the file will be written and invalidate _CompileAppManifest -->
<WriteLinesToFile
File="$(_CompileAppManifestInputFile)"
Lines="@(_CompileAppManifestInputLine)"
Overwrite="true"
WriteOnlyWhenDifferent="true"
/>
<ItemGroup>
<FileWrites Include="$(_CompileAppManifestInputFile)" />
</ItemGroup>
</Target>

<!-- NOTE: Keep new parameters to <CompileAppManifest/> in sync with @(_CompileAppManifestInputLine) above -->
<Target Name="_CompileAppManifest"
Condition="'$(_BundleOriginalResources)' != 'true'"
DependsOnTargets="$(_CompileAppManifestDependsOn)"
Inputs="@(_CompileAppManifestInputFile)"
Outputs="$(_TemporaryAppManifest)"
>

<ItemGroup>
<_FontFilesToRegister Include="@(BundleResource)" Condition="'%(BundleResource.RegisterFont)' == 'true'" />
</ItemGroup>

<CompileAppManifest
SessionId="$(BuildSessionId)"
Condition="'$(IsMacEnabled)' == 'true' Or '$(IsHotRestartBuild)' == 'true'"
AppBundleName="$(_AppBundleName)"
ApplicationDisplayVersion="$(ApplicationDisplayVersion)"
ApplicationId="$(ApplicationId)"
ApplicationTitle="$(ApplicationTitle)"
ApplicationVersion="$(ApplicationVersion)"
ApplicationDisplayVersion="$(ApplicationDisplayVersion)"
AppBundleName="$(_AppBundleName)"
AppManifest="$(AppBundleManifest)"
AssemblyName="$(AssemblyName)"
CompiledAppManifest="$(_TemporaryAppManifest)"
Debug="$(_BundlerDebug)"
DebugIPAddresses="$(_DebugIPAddresses)"
DefaultSdkVersion="$(_SdkVersion)"
FontFilesToRegister="@(_FontFilesToRegister)"
GenerateApplicationManifest="$(GenerateApplicationManifest)"
Expand All @@ -630,12 +688,11 @@ Copyright (C) 2018 Microsoft. All rights reserved.
ProjectDir="$(MSBuildProjectDirectory)"
ResourcePrefix="$(_ResourcePrefix)"
ResourceRules="$(_PreparedResourceRules)"
TargetArchitectures="$(TargetArchitectures)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
SdkIsSimulator="$(_SdkIsSimulator)"
SdkVersion="$(_SdkVersion)"
SupportedOSPlatformVersion="$(SupportedOSPlatformVersion)"
DebugIPAddresses="$(_DebugIPAddresses)"
TargetArchitectures="$(TargetArchitectures)"
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
Validate="$(_CreateAppManifest)"
>
</CompileAppManifest>
Expand Down
10 changes: 10 additions & 0 deletions tests/dotnet/UnitTests/PartialAppManifestTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@ public void Build (ApplePlatform platform, string runtimeIdentifiers)
Assert.AreEqual ("3.14", infoPlist.GetString ("CFBundleVersion").Value, "CFBundleVersion");
Assert.AreEqual ("3.14", infoPlist.GetString ("CFBundleShortVersionString").Value, "CFBundleShortVersionString");
Assert.AreEqual ("SomeValue", infoPlist.GetString ("Something").Value, "Something");

var partialAppManifestPath = Path.Combine (Path.GetDirectoryName (project_path)!, "..", "Partial.plist");
Configuration.Touch (partialAppManifestPath);
var rv = DotNet.AssertBuild (project_path, GetDefaultProperties (runtimeIdentifiers));
var allTargets = BinLog.GetAllTargets (rv.BinLogPath);
AssertTargetExecuted (allTargets, "_CompileAppManifest", "_CompileAppManifest rebuild");

rv = DotNet.AssertBuild (project_path, GetDefaultProperties (runtimeIdentifiers));
allTargets = BinLog.GetAllTargets (rv.BinLogPath);
AssertTargetNotExecuted (allTargets, "_CompileAppManifest", "_CompileAppManifest rebuild 2");
}
}
}
10 changes: 10 additions & 0 deletions tests/dotnet/UnitTests/ProjectTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -786,6 +786,16 @@ public void AppWithResources (ApplePlatform platform, string runtimeIdentifiers)
Assert.AreEqual (runtimeIdentifiers.Split (';').Any (v => v.EndsWith ("-arm64")), File.Exists (arm64txt), "arm64.txt");
Assert.AreEqual (runtimeIdentifiers.Split (';').Any (v => v.EndsWith ("-arm")), File.Exists (armtxt), "arm.txt");
Assert.AreEqual (runtimeIdentifiers.Split (';').Any (v => v.EndsWith ("-x64")), File.Exists (x64txt), "x64.txt");

var b_otf = Path.Combine (Path.GetDirectoryName (project_path)!, "Resources", "B.otf");
Configuration.Touch (b_otf);
var rv = DotNet.AssertBuild (project_path, GetDefaultProperties (runtimeIdentifiers));
var allTargets = BinLog.GetAllTargets (rv.BinLogPath);
AssertTargetExecuted (allTargets, "_CompileAppManifest", "_CompileAppManifest rebuild");

rv = DotNet.AssertBuild (project_path, GetDefaultProperties (runtimeIdentifiers));
allTargets = BinLog.GetAllTargets (rv.BinLogPath);
AssertTargetNotExecuted (allTargets, "_CompileAppManifest", "_CompileAppManifest rebuild 2");
}

[Category ("Windows")]
Expand Down
6 changes: 6 additions & 0 deletions tests/dotnet/UnitTests/WindowsTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,32 +234,38 @@ public void BundleStructureWithRemoteMac (ApplePlatform platform, string runtime
Configuration.Touch (appDelegatePath);

rv = DotNet.AssertBuild (project_path, properties);
var allTargets = BinLog.GetAllTargets (rv.BinLogPath);
warnings = BinLog.GetBuildLogWarnings (rv.BinLogPath).ToArray ();
warningMessages = BundleStructureTest.FilterWarnings (warnings, canonicalizePaths: true);

BundleStructureTest.CheckZippedAppBundleContents (platform, zippedAppBundlePath, rids, signature, isReleaseBuild);
AssertWarningsEqual (expectedWarnings, warningMessages, "Warnings Rebuild 1");
AssertTargetNotExecuted (allTargets, "_CompileAppManifest", "_CompileAppManifest Rebuild 1");
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);

// remove the bin directory, and rebuild should succeed and do the right thing
var binDirectory = Path.Combine (Path.GetDirectoryName (project_path)!, "bin");
Directory.Delete (binDirectory, true);

rv = DotNet.AssertBuild (project_path, properties);
allTargets = BinLog.GetAllTargets (rv.BinLogPath);
warnings = BinLog.GetBuildLogWarnings (rv.BinLogPath).ToArray ();
warningMessages = BundleStructureTest.FilterWarnings (warnings, canonicalizePaths: true);

BundleStructureTest.CheckZippedAppBundleContents (platform, zippedAppBundlePath, rids, signature, isReleaseBuild);
AssertWarningsEqual (expectedWarnings, warningMessages, "Warnings Rebuild 2");
AssertTargetNotExecuted (allTargets, "_CompileAppManifest", "_CompileAppManifest Rebuild 2");
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);

// a simple rebuild should succeed
rv = DotNet.AssertBuild (project_path, properties);
allTargets = BinLog.GetAllTargets (rv.BinLogPath);
warnings = BinLog.GetBuildLogWarnings (rv.BinLogPath).ToArray ();
warningMessages = BundleStructureTest.FilterWarnings (warnings, canonicalizePaths: true);

BundleStructureTest.CheckZippedAppBundleContents (platform, zippedAppBundlePath, rids, signature, isReleaseBuild);
AssertWarningsEqual (expectedWarnings, warningMessages, "Warnings Rebuild 3");
AssertTargetNotExecuted (allTargets, "_CompileAppManifest", "_CompileAppManifest Rebuild 3");
ExecuteWithMagicWordAndAssert (platform, runtimeIdentifiers, appExecutable);
}

Expand Down
Loading