Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Xamarin.Android.Build.Tasks] DTBs and _ResolveLibraryProjectImports (#…
…3891) I spent a little time looking at build logs of design-time builds inside VS Windows. To trigger these, I was editing an `.axml` file and saving it. I found some perf issues... The first thing I noticed was that `_ResolveLibraryProjectImports` runs on every DTB: Building target "_ResolveLibraryProjectImports" completely.I spent a little time looking at build logs of design-time builds inside VS Windows. To trigger these, I was editing an `.axml` file and saving it. I found some perf issues... The first thing I noticed was that the `_ResolveLibraryProjectImports` target runs on every DTB: Building target "_ResolveLibraryProjectImports" completely. Input file "obj\Debug\100\designtime\build.props" is newer than output file "obj\Debug\100\stamp\_ResolveLibraryProjectImports.stamp". Then I looked at how `build.props` was actually changing between different targets such as: * `UpdateGeneratedFiles`: the general DTB target * `SetupDependenciesForDesigner`: the Android designer runs this target Comparing the files, I saw this difference: - AndroidSdkPath = C:\Program Files (x86)\Android\android-sdk + AndroidSdkPath = C:\Program Files (x86)\Android\android-sdk\ - AndroidNdkPath = C:\Program Files (x86)\Android\android-sdk\ndk-bundle + AndroidNdkPath = C:\Program Files (x86)\Android\android-sdk\ndk-bundle\ - JavaSdkPath = C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25 + JavaSdkPath = C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\ So in some cases the `_ResolveMonoAndroidSdks` target is running to normalize the paths and other times not! The `_CreatePropertiesCache` target should depend on the `_ResolveMonoAndroidSdks` target to fix this issue. After that I found the *next* issue: - DesignTimeBuild = True + DesignTimeBuild = true What??? It appears that the casing differs depending on which part of the IDE is triggering the build. I suspect the designer is using one casing while VS proper uses another. I think we should call `ToLowerInvariant()` on every line in the `build.props` file to work around MSBuild's case insensitivity. This change saves ~350ms on every design-time build. However, if `build.props` changes all the time it may do even better, since `build.props` triggers almost all MSBuild targets in Xamarin.Android. Input file "obj\Debug\100\designtime\build.props" is newer than output file "obj\Debug\100\stamp\_ResolveLibraryProjectImports.stamp". Then I looked at how `build.props` was actually changing between different targets such as: * `UpdateGeneratedFiles` - the general DTB target * `SetupDependenciesForDesigner` - the Android designer runs this target Comparing the files, I saw this difference: - AndroidSdkPath = C:\Program Files (x86)\Android\android-sdk + AndroidSdkPath = C:\Program Files (x86)\Android\android-sdk\ - AndroidNdkPath = C:\Program Files (x86)\Android\android-sdk\ndk-bundle + AndroidNdkPath = C:\Program Files (x86)\Android\android-sdk\ndk-bundle\ - JavaSdkPath = C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25 + JavaSdkPath = C:\Program Files\Android\Jdk\microsoft_dist_openjdk_1.8.0.25\ So in some cases `_ResolveMonoAndroidSdks` is running to normalize the paths and other times not... `_CreatePropertiesCache` should depend on `_ResolveMonoAndroidSdks` to fix this issue. After that I found the *next* issue: - DesignTimeBuild = True + DesignTimeBuild = true What??? It appears that the casing differs depending on which part of the IDE is triggering the build. I suspect the designer is using one casing while VS proper uses another. I think we should call `ToLowerInvariant()` on every line in the `build.props` file to work around MSBuild's case insensitivity. This change saves ~350ms on every design-time build. However, if `build.props` changes all the time it may do even better, since `build.props` triggers almost all MSBuild targets in Xamarin.Android.
- Loading branch information