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] DTBs and _ResolveLibraryProjectImports #3891

Merged

Conversation

jonathanpeppers
Copy link
Member

@jonathanpeppers jonathanpeppers commented Nov 8, 2019

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.
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.

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.
    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.
@jonpryor jonpryor merged commit 58b47b7 into dotnet:master Nov 12, 2019
@jonathanpeppers jonathanpeppers deleted the dtb-resolvelibraryprojectimports branch November 12, 2019 17:17
jonpryor pushed a commit that referenced this pull request Nov 12, 2019
…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.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants