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

[Xamarin.Android.Build.Tasks] _LinkAssembliesNoShrink timestamps #2028

Merged
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: 1 addition & 3 deletions src/Xamarin.Android.Build.Tasks/Tasks/LinkAssemblies.cs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,8 @@ bool Execute (DirectoryAssemblyResolver res)
// We cannot just copy the linker output from *current* run output, because
// it always renew the assemblies, in *different* binary values, whereas
// the dll in the OptionalDestinationDirectory must retain old and unchanged.
if (File.Exists (assemblyDestination)) {
MonoAndroidHelper.SetLastAccessAndWriteTimeUtc (assemblyDestination, DateTime.UtcNow, Log);
if (File.Exists (assemblyDestination))
continue;
}
} else {
// Prefer fixup assemblies if exists, otherwise just copy the original.
copysrc = Path.Combine (OutputDirectory, filename);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,11 +205,13 @@ public void TargetFrameworkMonikerAssemblyAttributesPath ()
}

[Test]
public void CheckTimestamps ()
public void CheckTimestamps ([Values (true, false)] bool isRelease)
{
var start = DateTime.UtcNow.AddSeconds (-1);
var proj = new XamarinAndroidApplicationProject ();
using (var b = CreateApkBuilder ("temp/CheckTimestamps")) {
var proj = new XamarinAndroidApplicationProject {
IsRelease = isRelease,
};
using (var b = CreateApkBuilder (Path.Combine ("temp", TestName))) {
//To be sure we are at a clean state, delete bin/obj
var intermediate = Path.Combine (Root, b.ProjectDirectory, proj.IntermediateOutputPath);
if (Directory.Exists (intermediate))
Expand Down Expand Up @@ -240,7 +242,8 @@ public void CheckTimestamps ()

//One last build with no changes
Assert.IsTrue (b.Build (proj), "third build should have succeeded.");
Assert.IsTrue (b.Output.IsTargetSkipped ("_LinkAssembliesNoShrink"), "`_LinkAssembliesNoShrink` should be skipped!");
string targetName = isRelease ? "_LinkAssembliesShrink" : "_LinkAssembliesNoShrink";
Assert.IsTrue (b.Output.IsTargetSkipped (targetName), $"`{targetName}` should be skipped!");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2078,7 +2078,13 @@ because xbuild doesn't support framework reference assemblies.
LinkOnlyNewerThan="$(_AndroidLinkFlag)"
ResolvedAssemblies="@(ResolvedAssemblies)" />

<!-- We don't have to depend on flag file for NoShrink, but it is used to check timestamp -->
<!--NOTE: the linker's use of File.Copy requires us to update the timestamps of output files -->
<ItemGroup>
<_FilesToTouch Include="$(MonoAndroidIntermediateAssemblyTempDir)*" />
</ItemGroup>
<Touch Files="@(_FilesToTouch)" />

<!-- We don't have to depend on flag file for NoShrink, but it is used to check timestamp -->
<Touch Files="$(_AndroidLinkFlag)" AlwaysCreate="true" />
</Target>

Expand Down