From 3dc914dae8d6b2d16f5e7de5d1dc5c47fb1f90b2 Mon Sep 17 00:00:00 2001 From: Jonathan Peppers Date: Mon, 29 Oct 2018 11:04:34 -0500 Subject: [PATCH] [Xamarin.Android.Build.Tasks] target to simplify @(FileWrites) (#2344) In our "MSBuild Best Practices" guide, the convention for using a "stamp" file has a bit of boilerplate: `` the file, then add the file to the `@(FileWrites)` group: It is reasonably easy to mess this up. If we add a new `_AddFilesToFileWrites` target which runs before the `IncrementalClean` target and automatically adds `$(_AndroidStampDirectory)*.stamp` to `@(FileWrites)`, we can simplify things by only requiring the ``: This should be less prone to mistakes. --- Documentation/guides/MSBuildBestPractices.md | 10 +++++++++- .../Xamarin.Android.Common.targets | 20 +++++++------------ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Documentation/guides/MSBuildBestPractices.md b/Documentation/guides/MSBuildBestPractices.md index ac2830a8def..7827540e5e9 100644 --- a/Documentation/guides/MSBuildBestPractices.md +++ b/Documentation/guides/MSBuildBestPractices.md @@ -220,8 +220,16 @@ We should also name the stamp file the same as the target, such as: Outputs="$(_AndroidStampDirectory)_ResolveLibraryProjectImports.stamp"> + +``` + +Do we need `FileWrites` here? Nope. The `_AddFilesToFileWrites` +target takes care of it, so we can't as easily mess it up: + +```xml + - + ``` diff --git a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets index 83d3cb2d3f5..50fd3e8dd35 100755 --- a/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets +++ b/src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets @@ -469,7 +469,6 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. - @@ -662,9 +661,6 @@ Copyright (C) 2011-2012 Xamarin. All rights reserved. - - - @@ -1323,9 +1319,6 @@ because xbuild doesn't support framework reference assemblies. OutputImportDirectory="$(_AndroidLibrayProjectIntermediatePath)"> - - - - - - @@ -2298,9 +2288,6 @@ because xbuild doesn't support framework reference assemblies. TargetFrameworkVersion="$(TargetFrameworkVersion)" Manifest="$(IntermediateOutputPath)android\AndroidManifest.xml" /> - - - @@ -3058,6 +3045,13 @@ because xbuild doesn't support framework reference assemblies. + + + + + + +