Skip to content

[build] Fix the Linux build - #394

Merged
atsushieno merged 1 commit into
dotnet:masterfrom
jonpryor:jonp-xbuild-linux
Jan 23, 2017
Merged

[build] Fix the Linux build#394
atsushieno merged 1 commit into
dotnet:masterfrom
jonpryor:jonp-xbuild-linux

Conversation

@jonpryor

Copy link
Copy Markdown
Contributor

As feared, commit 743529c's removal of $(TargetFrameworkRootPath)
broke the Linux build:

Gui/Activities/TestSuiteActivity.cs(25,35): error CS0012: The type `System.IDisposable' is defined in an assembly that is not referenced.
Consider adding a reference to assembly `System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

macOS is unaffected as it's unfortunately using System files:

Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0'

(Heavy sigh.)

Thus, our scenario: msbuild doesn't like setting
$(TargetFrameworkRootPath), yet $(TargetFrameworkRootPath) needs
to be set for Linux to build, because Linux doesn't have a system-wide
Xamarin.Android install. (Not that we want to require a
Xamarin.Android install! But that's just why macOS is building...)

The fix? Split the difference, somewhat. We can't set
$(TargetFrameworkRootPath) for everything, but we can override
it for specific projects. Update Mono.Data.Sqlite.csproj,
Mono.Posix.csproj, OpenTK.csproj,
System.Drawing.Primitives.csproj, and
Xamarin.Android.NUnitLite.csproj to override
$(TargetFrameworkRootPath) appropriately, so that they resolve the
MonoAndroid framework assemblies from the internal build tree.

What's left is Mono.Android.csproj and Mono.Android.Export.csproj,
which don't <Import/> Xamarin.Android.CSharp.targets. These are
the projects that needed to "hack in" a @(Reference) to
System.Runtime in 7343965, which was removed in 743529c. The fix is
more voodoo in each of them:

  • Set $(ImplicitlyExpandDesignTimeFacades)=True, so System.Runtime
    can be found
  • Set $(TargetFrameworkIdentifier)=MonoAndroid, so we're looking for
    the correct framework
  • Set $(TargetFrameworkRootPath) so that the MonoAndroid framework
    can be found in the local build tree.
  • Set $(TargetFrameworkVersion) to a valid MonoAndroid framework
    version number.

This allows Mono.Android.Export.csproj. Mono.Android.csproj needs
one more fix: in order for frameworks to be resolved from a "clean"
state, RedistList\FrameworkList.xml must exist before attempting to
resolve assemblies. Fix the _GenerateFrameworkList target so that
FrameworkList.xml is created before the ResolveReferences
target, thus allowing the MonoAndroid,v7.1 framework to be found.

As feared, commit 743529c's removal of `$(TargetFrameworkRootPath)`
[broke the Linux build][0]:

	Gui/Activities/TestSuiteActivity.cs(25,35): error CS0012: The type `System.IDisposable' is defined in an assembly that is not referenced.
	Consider adding a reference to assembly `System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

macOS is unaffected as [it's unfortunately using System files][1]:

	Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0'

(Heavy sigh.)

Thus, our scenario: `msbuild` doesn't like setting
`$(TargetFrameworkRootPath)`, yet `$(TargetFrameworkRootPath)` needs
to be set for Linux to build, because Linux doesn't have a system-wide
Xamarin.Android install. (Not that we want to require a
Xamarin.Android install! But that's just why macOS is building...)

The fix? Split the difference, somewhat. We can't set
`$(TargetFrameworkRootPath)` for *everything*, but we *can* override
it for *specific projects*. Update `Mono.Data.Sqlite.csproj`,
`Mono.Posix.csproj`, `OpenTK.csproj`,
`System.Drawing.Primitives.csproj`, and
`Xamarin.Android.NUnitLite.csproj` to override
`$(TargetFrameworkRootPath)` appropriately, so that they resolve the
`MonoAndroid` framework assemblies from the internal build tree.

What's left is `Mono.Android.csproj` and `Mono.Android.Export.csproj`,
which don't `<Import/>` `Xamarin.Android.CSharp.targets`. These are
the projects that needed to "hack in" a `@(Reference)` to
`System.Runtime` in 7343965, which was removed in 743529c. The fix is
more voodoo in each of them:

* Set `$(ImplicitlyExpandDesignTimeFacades)`=True, so `System.Runtime`
    can be found
* Set `$(TargetFrameworkIdentifier)`=MonoAndroid, so we're looking for
    the correct framework
* Set `$(TargetFrameworkRootPath)` so that the MonoAndroid framework
    can be found in the local build tree.
* Set `$(TargetFrameworkVersion)` to a valid MonoAndroid framework
    version number.

This allows `Mono.Android.Export.csproj`. `Mono.Android.csproj` needs
one more fix: in order for frameworks to be resolved from a "clean"
state, `RedistList\FrameworkList.xml` must exist before attempting to
resolve assemblies. Fix the `_GenerateFrameworkList` target so that
`FrameworkList.xml` is created *before* the `ResolveReferences`
target, thus allowing the `MonoAndroid,v7.1` framework to be found.

[0]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-linux/173/
[1]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/207/consoleText
@dellis1972

Copy link
Copy Markdown
Contributor

changes look ok. If someone can confirm it works on line then I'll merge. @atsushieno @grendello ?

@atsushieno
atsushieno merged commit 61b21bc into dotnet:master Jan 23, 2017
jonpryor added a commit that referenced this pull request Jan 25, 2017
Reverts #394 (commit 61b21bc).

[It broke the build][b209]:

	Java.Lang/Object.cs(15,5): error CS0012: The type `System.IDisposable' is defined in an assembly that is not referenced.
    Consider adding a reference to assembly `System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

Doubly odd, I *thought* that this had successfully gone through the
PR builder, but I can't find an actual PR build for this PR!

Revert the attempted Linux build fix. We want things building, which
will allow me time to investigate a better Linux fix.

[b209]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/209/
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Jan 25, 2017
As feared, commit 743529c's removal of `$(TargetFrameworkRootPath)`
[broke the Linux build][0]:

	Gui/Activities/TestSuiteActivity.cs(25,35): error CS0012: The type `System.IDisposable' is defined in an assembly that is not referenced.
	Consider adding a reference to assembly `System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

macOS is unaffected as [it's unfortunately using System files][1]:

	Found framework definition list '/Library/Frameworks/Mono.framework/External/xbuild-frameworks/MonoAndroid/v1.0/RedistList/FrameworkList.xml' for framework 'MonoAndroid,Version=v1.0'

(Heavy sigh.)

Thus, our scenario: `msbuild` doesn't like setting
`$(TargetFrameworkRootPath)`, yet `$(TargetFrameworkRootPath)` needs
to be set for Linux to build, because Linux doesn't have a system-wide
Xamarin.Android install. (Not that we want to require a
Xamarin.Android install! But that's just why macOS is building...)

The fix? Split the difference, somewhat. We can't set
`$(TargetFrameworkRootPath)` for *everything*, but we *can* override
it for *specific projects*. Update `Mono.Data.Sqlite.csproj`,
`Mono.Posix.csproj`, `OpenTK.csproj`,
`System.Drawing.Primitives.csproj`, and
`Xamarin.Android.NUnitLite.csproj` to override
`$(TargetFrameworkRootPath)` appropriately, so that they resolve the
`MonoAndroid` framework assemblies from the internal build tree.

What's left is `Mono.Android.csproj` and `Mono.Android.Export.csproj`,
which don't `<Import/>` `Xamarin.Android.CSharp.targets`. These are
the projects that needed to "hack in" a `@(Reference)` to
`System.Runtime` in 7343965, which was removed in 743529c. The fix is
more voodoo in each of them:

* Set `$(ImplicitlyExpandDesignTimeFacades)`=True, so `System.Runtime`
    can be found
* Set `$(TargetFrameworkIdentifier)`=MonoAndroid, so we're looking for
    the correct framework
* Set `$(TargetFrameworkRootPath)` so that the MonoAndroid framework
    can be found in the local build tree.
* Set `$(TargetFrameworkVersion)` to a valid MonoAndroid framework
    version number.

This allows `Mono.Android.Export.csproj`. `Mono.Android.csproj` needs
one more fix: in order for frameworks to be resolved from a "clean"
state, `RedistList\FrameworkList.xml` must exist before attempting to
resolve assemblies. Fix the `_GenerateFrameworkList` target so that
`FrameworkList.xml` is created *before* the `ResolveReferences`
target, thus allowing the `MonoAndroid,v7.1` framework to be found.

[0]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android-linux/173/
[1]: https://jenkins.mono-project.com/view/Xamarin.Android/job/xamarin-android/207/consoleText
@github-actions github-actions Bot locked and limited conversation to collaborators Feb 6, 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.

4 participants