Skip to content

Conversation

@jonpryor
Copy link
Contributor

@jonpryor jonpryor commented May 6, 2016

Rebuilding the Xamarin.Android.Build.Tasks project would fail:

$ xbuild
# works

# "change a file
$ touch Tasks/Aapt.cs

# Rebuild; should work, right?
$ xbuild
    Tasks/LinkAssemblies.cs(103,32): error CS0117: `Xamarin.Android.Tasks.Profile' does not contain a definition for `SharedRuntimeAssemblies'
    Utilities/MonoAndroidHelper.cs(230,16): error CS0117: `Xamarin.Android.Tasks.Profile' does not contain a definition for `SharedRuntimeAssemblies'

# wat?

The problem was due to a3dfd4c and 59ec488:

  1. In 59ec488, Xamarin.Android.Build.Tasks.targets was included
    before including $(MSBuildToolsPath)\Microsoft.CSharp.targets.
    This meant that $(IntermediateOutputPath) wasn't set when
    Xamarin.Android.Build.Tasks.targets was imported, and thus
    $(_GeneratedProfileClass) contained no directory name.
  2. In a3dfd4c, the @(Compile) item group was only updated when the
    _GenerateProfileClass target was executed, which only happened
    when $(_GeneratedProfileClass) didn't exist. This is why it
    works on the initial build but not subsequent builds.

Things worked prior to a3dfd4c because the _Foo target always
executed, and thus @(Compile) always contained the generated
Profile.g.cs file.

Fix the <Import/> ordering issue (1), and instead of updating
@(Compile) when the target executes, just add the generated file to
@(Compile) within Xamarin.Android.Build.Tasks.csproj (2).

Rebuilding the Xamarin.Android.Build.Tasks project would fail:

	$ xbuild
	# works

	# "change a file
	$ touch Tasks/Aapt.cs

	# Rebuild; should work, right?
	$ xbuild
		Tasks/LinkAssemblies.cs(103,32): error CS0117: `Xamarin.Android.Tasks.Profile' does not contain a definition for `SharedRuntimeAssemblies'
		Utilities/MonoAndroidHelper.cs(230,16): error CS0117: `Xamarin.Android.Tasks.Profile' does not contain a definition for `SharedRuntimeAssemblies'

	# wat?

The problem was due to a3dfd4c *and* 59ec488:

1. In 59ec488, `Xamarin.Android.Build.Tasks.targets` was included
    *before* including `$(MSBuildToolsPath)\Microsoft.CSharp.targets`.
    This meant that `$(IntermediateOutputPath)` wasn't set when
    `Xamarin.Android.Build.Tasks.targets` was imported, and thus
    `$(_GeneratedProfileClass)` contained no directory name.

2. In a3dfd4c, the `@(Compile)` item group was only updated when the
    `_GenerateProfileClass` target was executed, which only happened
    when `$(_GeneratedProfileClass)` didn't exist. This is why it
    works on the initial build but not subsequent builds.

Things worked prior to a3dfd4c because the `_Foo` target *always*
executed, and thus `@(Compile)` always contained the generated
Profile.g.cs file.

Fix the `<Import/>` ordering issue (1), and instead of updating
`@(Compile)` when the target executes, just add the generated file to
`@(Compile)` within Xamarin.Android.Build.Tasks.csproj (2).
@dellis1972 dellis1972 merged commit 2441dd1 into dotnet:master May 6, 2016
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Dec 14, 2020
jonpryor added a commit that referenced this pull request Dec 15, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Feb 2, 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.

3 participants