From 67650d8ad4570ed4ffe968af3d5f4c38d5b9f83f Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Wed, 31 Jan 2018 20:34:20 +0000 Subject: [PATCH 1/3] [Xamarin.Android.Build.Tasks] Stop IncrementalClean removing assemblies. (#1255) Fixes: https://github.com/xamarin/xamarin-android/issues/1164 Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=61108 The `IncrementalClean` target basically deletes a ton of stuff if it's not in the `@(FileWrites)` group. Under certain conditons this include assemblies in `$(OutDir)`. It mainly effects projects which use a shared `$(OutDir)`. So if a third level dependency is copied to the `$(OutDir)` but is not referenced by the main app project we end up with the `IncrementalClean` target deleting the file. This then breaks packaging since we expect the file to exist. This causes problems with TFS because it seems to ALWAYS use a shared `$(OutDir)`. To work around this problem we just need to tell the `IncrementalClean` target to ignore any dll in the `$(OutDir)`. Since we already have a target in place to handle this we can just expand the list of files it should be ignoring. --- .../ImportAfter/Xamarin.Android.Windows.targets | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets index 0134033df70..7902eedd7da 100644 --- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets +++ b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets @@ -11,16 +11,16 @@ Copyright (C) 2014 Xamarin. All rights reserved. Xamarin + <_IsRunningXBuild Condition=" '$(MSBuildRuntimeVersion)' == '' ">true - - - - + + + + - From 5f50dbfff327aea8c878884d8833b680f6203904 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Thu, 1 Feb 2018 22:32:50 +0000 Subject: [PATCH 2/3] [Xamarin.Android.Build.Tasks] Fix Conditon on _RegisterAndroidFilesWithFileWrites (#1265) Commit 20123b5 broke the build system on Windows. The condition on `_RegisterAndroidFilesWithFileWrites` was incorrect. `$(_IsRunningXBuild)` can be empty when running under MSBuild. As a result the condition will always result in the target being skipped. This commit fixes the condition to that it will run correctly under msbuild and is skipped on xbuild. --- .../ImportAfter/Xamarin.Android.Windows.targets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets index 7902eedd7da..7b16e67727c 100644 --- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets +++ b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets @@ -14,7 +14,7 @@ Copyright (C) 2014 Xamarin. All rights reserved. <_IsRunningXBuild Condition=" '$(MSBuildRuntimeVersion)' == '' ">true - + From be0c744529c07e5f40c7e330b41154bb5dd3ddb2 Mon Sep 17 00:00:00 2001 From: Dean Ellis Date: Thu, 15 Feb 2018 02:38:56 +0000 Subject: [PATCH 3/3] [Xamarin.Android.Build.Tasks] Stop designtime designer being deleted. (#1307) Fixes: https://github.com/xamarin/xamarin-android/issues/1286 We have a number of problems with our DesignTime build system. The main one which this PR addresses is the designer file is deleted by `IncrementalClean` AND `CoreClean`. This them completely messes up the DesignTime system since it can no longer find the file. So what we should be doing is making sure we don't tell the build system about the designer file ;-). We do this by not writing the path to the `$(CleanFile)`. ~~ Some background on the [DesignTime build system][2] ~~ The primary entry point is the `CoreCompile` target, with occasional calls to the `RefreshReferences` target. In theory [`$(DesignTimeBuild)`][1] should be set to `true`; however, this is not always the case which is why we have the `_SetupForDesignTimeBuild` target which hooks into the `CoreCompile` target. Additionally, `$(BuildingProject)` should be False. ([Additional information][2]). However this document is not seem to be 100% accurate since the IDE's (namely Visual Studio) do not always set the required properties. One of the key requirements for design time builds seems to be that they are independent of the main builds. The files it uses should not be removed since the `CoreCompile` target does not seem to be called consistently. For example, if the designer file is removed and the `RefreshReferences` target is called, the design time build may well fail because the targets required to re-generate the designer file are not called. Now for the problem: the `IncrementalClean` target runs between builds. It seems to want to remove files from the previous build. I suspect the purpose is to remove files that are no longer needed. (For example an assembly which is no longer referenced.) The problem is that we have a file (the design time `Resource.designer.cs`) which is not built as part of the normal build. But this file was still being written to `$(CleanFile)` which is the driver for the `IncrementalClean` process. As a result, the file gets removed because its not in the list of current `@(FileWrites)`. Not writing the name of this file to `$(CleanFile)` seems to hide it from `IncrementalClean`. There was also another problem with the `CoreClean` target. This was also removing the designer files. Again this was down to the fact that the file was listed in `$(CleanFile)`. However our older workarounds did not work since they relied on `IncrementalClean` running. For a `Clean` target invocation it does not. Again the solution seems to be Don't Write the file to `$(CleanFile)`, which is counterintuitive since we are told to write all files we generate to that file. [1]: https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md#determining-whether-a-target-is-run-in-a-design-time-build [2]: https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md --- .../Xamarin.Android.Windows.targets | 2 +- .../AndroidUpdateResourcesTest.cs | 6 +- .../IncrementalBuildTest.cs | 79 +++++++++++++++++++ .../Xamarin.Android.Common.targets | 5 -- 4 files changed, 83 insertions(+), 9 deletions(-) diff --git a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets index 7b16e67727c..623dda9c056 100644 --- a/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets +++ b/src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets @@ -15,7 +15,7 @@ Copyright (C) 2014 Xamarin. All rights reserved. - + @" +using System; +namespace Lib +{ + public class Class1 + { + public Class1 () + { + } + } +}" + }; + var lib = new XamarinAndroidLibraryProject () { + ProjectName = "Lib", + ProjectGuid = Guid.NewGuid ().ToString (), + Sources = { + class1Source, + }, + }; + using (var b = CreateDllBuilder (Path.Combine (testPath, "Lib"))) { + Assert.IsTrue (b.Build (lib), "Build should have succeeded."); + Assert.IsTrue (b.LastBuildOutput.ContainsText ("LogicalName=__AndroidLibraryProjects__.zip") || + b.LastBuildOutput.ContainsText ("Lib.obj.Debug.__AndroidLibraryProjects__.zip,__AndroidLibraryProjects__.zip"), + "The LogicalName for __AndroidLibraryProjects__.zip should be set."); + class1Source.Timestamp = DateTime.UtcNow.Add (TimeSpan.FromMinutes (1)); + Assert.IsTrue (b.Build (lib), "Build should have succeeded."); + Assert.IsTrue (b.LastBuildOutput.ContainsText ("LogicalName=__AndroidLibraryProjects__.zip") || + b.LastBuildOutput.ContainsText ("Lib.obj.Debug.__AndroidLibraryProjects__.zip,__AndroidLibraryProjects__.zip"), + "The LogicalName for __AndroidLibraryProjects__.zip should be set."); + } + } + [Test] public void AllProjectsHaveSameOutputDirectory() { diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index c9b90c4502d..ea44cc8b991 100755 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -1107,11 +1107,6 @@ because xbuild doesn't support framework reference assemblies. -