Skip to content

Eliminate all "BeforeTargets" and "AfterTargets" from our own MSBuild targets #1128

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

Closed
atsushieno opened this issue Dec 20, 2017 · 0 comments
Labels
Area: xamarin-android Build Issues building the xamarin-android repo *itself*.

Comments

@atsushieno
Copy link
Contributor

We must eliminate all "BeforeTargets" and "AfterTargets" from our own MSBuild targets. They are MSBuild anti-patterns that confuses developers by messing dependency tracking hard, and can be replaced by MSBuild properties like <BuildDependsOn>.

(In case you don't know why BeforeTargets and AfterTargets must be eliminated read this post http://sedodream.com/2013/02/12/MSBuildDependsOnTargetsVersusBeforeTargetsAfterTargets.aspx especially this: "I always use DependsOnTargets unless there is a solid reason why I should chose to use Before/AfterTargets.")

Here is the list of current BeforeTargets usage

/sources/xamarin-android$ grep -R BeforeTargets | grep -v bin/Release | grep -v bin/Debug | grep -v external/mono | grep BeforeTargets
build-tools/create-vsix/create-vsix.targets:      BeforeTargets="VSIXContainerProjectOutputGroup;CreateVsixContainer"
build-tools/create-vsix/create-vsix.targets:      BeforeTargets="Build"
build-tools/create-vsix/create-vsix.targets:      BeforeTargets="GeneratePkgDef;VSCTCompile;VSIXNameProjectOutputGroup">
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets:      BeforeTargets="CoreCompile"
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets:      BeforeTargets="DeployOutputFiles"
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets:      BeforeTargets="CoreCompile"
src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Common/ImportAfter/Xamarin.Android.Windows.targets:	<Target Name="_RegisterMdbFilesWithFileWrites" BeforeTargets="IncrementalClean">  
src/Xamarin.Android.Build.Tasks/Xamarin.Android.Common.targets:<Target Name="_SetLatestTargetFrameworkVersionForPackageReference" BeforeTargets="_GetRestoreTargetFrameworksOutput" DependsOnTargets="_SetLatestTargetFrameworkVersion">
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs:<Target Name=""CustomTarget"" AfterTargets=""UpdateAndroidAssets"" BeforeTargets=""UpdateAndroidInterfaceProxies"" >
src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BuildTest.cs:<Target Name=""_CheckAbis"" BeforeTargets=""_DefineBuildTargetAbis"">
src/Mono.Android/Test/Mono.Android-Tests.targets:      BeforeTargets="Build"
src/Mono.Android/Mono.Android.targets:      BeforeTargets="BeforeResolveReferences"
src/Mono.Android/Mono.Android.targets:      BeforeTargets="CoreCompile"
src/Mono.Android/Mono.Android.targets:      BeforeTargets="CoreCompile"
src/Mono.Android/Mono.Android.targets:      BeforeTargets="_GenerateBinding"
src/Mono.Android/Mono.Android.targets:      BeforeTargets="CoreCompile"
src/Mono.Android/Mono.Android.targets:      BeforeTargets="GetTargetFrameworkProperties;GetReferenceAssemblyPaths;ResolveReferences"
src/Mono.Android/Mono.Android.targets:      BeforeTargets="_GenerateFrameworkList"
external/Java.Interop/packages/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.7/build/net45/Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props:  <Target Name="IncludeRoslynCompilerFilesToFilesForPackagingFromProject" BeforeTargets="PrepareForRun" >
external/Java.Interop/external/cecil/Mono.Cecil.Tests.props:          BeforeTargets="GenerateBindingRedirects"
tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.targets:      BeforeTargets="ResolveAssemblyReferences">
tests/Xamarin.Android.Bcl-Tests/Xamarin.Android.Bcl-Tests.targets:      BeforeTargets="ResolveAssemblyReferences"
@atsushieno atsushieno added the Area: xamarin-android Build Issues building the xamarin-android repo *itself*. label Dec 20, 2017
jonpryor pushed a commit that referenced this issue Oct 28, 2020
Fixes: xamarin/monodroid#1121
Fixes: xamarin/monodroid#1123

Changes: http://github.com/xamarin/monodroid/compare/767f647151936303c294d154d0d0a4da8b601464...04b0423ea298eda7263ba23e64df63c940ebddad

  * xamarin/monodroid@04b0423ea: Bump android-sdk-installer, androidtools, xamarin-android (#1128)
  * xamarin/monodroid@b0f824253: [tools/msbuild] Update RunActivity to use Async methods. (#1127)
  * xamarin/monodroid@ad6ea2a3c: [tools/msbuild] changes not deployed in some cases (#1125)
  * xamarin/monodroid@dfa0cba44: [tools/msbuild] Add check for 'ro.boot.disable_runas' (#1124)
  * xamarin/monodroid@3f2ca1173: [tools/msbuild] Add additional timing information for FastDeploy. (#1126)
  * xamarin/monodroid@d47db99c7: [tools/msbuild] fix _Run target for .NET 6 (#1118)
  * xamarin/monodroid@49a6dd572: Bump to xamarin/xamarin-android/master@e0999a43 (#1120)
@ghost ghost locked as resolved and limited conversation to collaborators Jun 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Area: xamarin-android Build Issues building the xamarin-android repo *itself*.
Projects
None yet
Development

No branches or pull requests

1 participant