Skip to content

Conversation

@pjcollins
Copy link
Member

@pjcollins pjcollins commented Dec 5, 2019

Context: #3928
Context: https://github.com/xamarin/monodroid/pull/1048

Attempts to clean up and modernize various projects to help break up the
scope of change required to convert them to .NET Standard libraries.

Updates the shared MSBuildReferences.projitems file to instead include
NuGet references to the required Microsoft.Build.* assemblies. The
Mono.Posix.NETStandard, Xamarin.Build.AsyncTask, and Xamarin.LibZipSharp
NuGet references have also been moved into this file to make it easier
to update versions in one place as needed. We're only using the compile
time assets from the MSBuild NuGet packages, which ensures that their
content is not copied to the output directory. An additional ItemGroup
has been added to this file to copy the required assemblies from the system
to the output directory so that Xamarin.Android.Build.Tests can run against
them. These changes are required because the MSBuild assemblies coming
from NuGet do not yet fully support running on Mono.

All projects which reference MSBuildReferences.projitems have been
converted from the old packages.config to the new PackageReference
NuGet reference style.

The Azure Pipeline build job has been updated to completely build
Xamarin.Android-Tests.sln with xabuild, rather than only building select
projects. This was done to mirror our Jenkins build and to ensure that
make all-tests continues to work moving forward.

.NET Core and NuGetCommand tasks have been bumped to bring
in a newer version of NuGet with better PackageReference support.

NuGet restore will be skipped if any issues occur when calculating the
dependency graph for the solution or project that it is operating on.
A lot of our sources attempt to import props/targets/projitems files
that are generated by the build, and these should be conditionally
imported so that NuGet restore attempts can succeed before these files
are generated. This should also help when loading these projects in
VS or VS Mac.

Example NuGet restore error:

src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets(8,3): error MSB4019: The imported project "bin/BuildRelease/ProfileAssemblies.projitems" was not found. Confirm that the expression in the Import declaration "../../bin/BuildRelease/ProfileAssemblies.projitems" is correct, and that the file exists on disk.
/var/folders/pp/x88nqyvd0h18ttl996vv2c3w0000gn/T/NuGetScratch/ok90j1ok.3t3.nugetrestore.targets(266,5): warning : Skipping restore for project 'src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj'. The project file may be invalid or missing targets required for restore.

I've also moved the NuGet.exe that is copied and used by tests into it's own
folder to avoid a crash on macOS which would occur when NuGet.exe is
invoked from the same folder as Xunit.NetCore.Extensions.dll:

mono bin/TestRelease/NuGet.exe

VTable setup of type Xunit.NetCore.Extensions.SkippedTestCase failed
System.TypeLoadException: VTable setup of type Xunit.NetCore.Extensions.SkippedTestCase failed
  at (wrapper managed-to-native) System.RuntimeType.GetPropertiesByName_native(System.RuntimeType,intptr,System.Reflection.BindingFlags,System.RuntimeType/MemberListType)
  at System.RuntimeType.GetPropertiesByName (System.String name, System.Reflection.BindingFlags bindingAttr, System.RuntimeType+MemberListType listType, System.RuntimeType reflectedType) [0x0001b] in <7d0bc631cadd4a07bf74717847e90cfa>:0
  at System.RuntimeType.GetPropertyCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Type[] types, System.Boolean allowPrefixLookup) [0x00010] in <7d0bc631cadd4a07bf74717847e90cfa>:0
  at System.RuntimeType.GetProperties (System.Reflection.BindingFlags bindingAttr) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0
  at System.ComponentModel.Composition.AttributedModel.AttributedPartCreationInfo+<GetExportMembers>d__32.MoveNext () [0x000eb] in <5e20d4aa8c6c44a89bf1aeb3c06f166c>:0
  at System.Linq.Enumerable.Any[TSource] (System.Collections.Generic.IEnumerable1[T] source) [0x00015] in <e22351e395f44d7b8c4860fca2dcee71>:0
  ...

@pjcollins pjcollins added the do-not-merge PR should not be merged. label Dec 5, 2019
@pjcollins
Copy link
Member Author

There's a macOS specific issue in Xamarin.Android.Build.Tests that I'm looking at now.

@pjcollins pjcollins force-pushed the pjcollins_monodroid-sdk-changes branch 2 times, most recently from 26fb7f7 to 0eb3222 Compare December 10, 2019 20:58
Updates the shared `MSBuildReferences.projitems` file to instead include
NuGet references to the required Microsoft.Build.* assemblies. The
Mono.Posix.NETStandard, Xamarin.Build.AsyncTask, and Xamarin.LibZipSharp
NuGet references have also been moved into this file to make it easier
to update versions as needed.

All projects which reference `MSBuildReferences.projitems` have been
converted from the old `packages.config` to the new `PackageReference`
NuGet reference style.
NuGet restore will be skipped if any issues occur when calculating the
dependency graph for the solution or project that it is operating on.
A lot of our sources attempt to import props/targets/projitems files
that are generated by the build, and these should be conditionally
imported so that NuGet restore attempts can succeed before these files
are generated.

Example NuGet restore error:

    src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.targets(8,3): error MSB4019: The imported project "bin/BuildRelease/ProfileAssemblies.projitems" was not found. Confirm that the expression in the Import declaration "../../bin/BuildRelease/ProfileAssemblies.projitems" is correct, and that the file exists on disk.
    /var/folders/pp/x88nqyvd0h18ttl996vv2c3w0000gn/T/NuGetScratch/ok90j1ok.3t3.nugetrestore.targets(266,5): warning : Skipping restore for project 'src/Xamarin.Android.Build.Tasks/Xamarin.Android.Build.Tasks.csproj'. The project file may be invalid or missing targets required for restore.
@pjcollins pjcollins force-pushed the pjcollins_monodroid-sdk-changes branch from 0eb3222 to f7d125a Compare December 12, 2019 15:24
`NuGet.exe` throws on macOS when it is invoked from the same folder as
`Xunit.NetCore.Extensions.dll`:

    mono bin/TestRelease/NuGet.exe

    VTable setup of type Xunit.NetCore.Extensions.SkippedTestCase failed
    System.TypeLoadException: VTable setup of type Xunit.NetCore.Extensions.SkippedTestCase failed
      at (wrapper managed-to-native) System.RuntimeType.GetPropertiesByName_native(System.RuntimeType,intptr,System.Reflection.BindingFlags,System.RuntimeType/MemberListType)
      at System.RuntimeType.GetPropertiesByName (System.String name, System.Reflection.BindingFlags bindingAttr, System.RuntimeType+MemberListType listType, System.RuntimeType reflectedType) [0x0001b] in <7d0bc631cadd4a07bf74717847e90cfa>:0
      at System.RuntimeType.GetPropertyCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Type[] types, System.Boolean allowPrefixLookup) [0x00010] in <7d0bc631cadd4a07bf74717847e90cfa>:0
      at System.RuntimeType.GetProperties (System.Reflection.BindingFlags bindingAttr) [0x00000] in <7d0bc631cadd4a07bf74717847e90cfa>:0
      at System.ComponentModel.Composition.AttributedModel.AttributedPartCreationInfo+<GetExportMembers>d__32.MoveNext () [0x000eb] in <5e20d4aa8c6c44a89bf1aeb3c06f166c>:0
      at System.Linq.Enumerable.Any[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x00015] in <e22351e395f44d7b8c4860fca2dcee71>:0
      ...

Move the copy of `NuGet.exe`into it's own folder to avoid this wierd
behavior when executing `Xamarin.Android.Build.Tests.dll` on macOS.
@pjcollins pjcollins force-pushed the pjcollins_monodroid-sdk-changes branch from 393650e to 61a4f06 Compare December 12, 2019 22:41
@pjcollins pjcollins force-pushed the pjcollins_monodroid-sdk-changes branch from 11b37ee to db45c8d Compare December 13, 2019 01:25
@pjcollins pjcollins force-pushed the pjcollins_monodroid-sdk-changes branch from db45c8d to 46640f2 Compare December 13, 2019 15:36
@pjcollins pjcollins removed the do-not-merge PR should not be merged. label Dec 13, 2019
@jonpryor jonpryor merged commit dc49cf9 into master Dec 16, 2019
@pjcollins pjcollins deleted the pjcollins_monodroid-sdk-changes branch December 16, 2019 20:47
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Dec 17, 2019
Attempting to use `@(PackageReference)` for `Mono.Linq.Expressions`
continues to fail, even after PR dotnet#3995.  Looking at the `msbuild
Xamarin.Android /t:Prepare` output [^0], I see that there is a
`nuget restore Xamarin.Android-Tests.sln`, and it does not always,
and it restores numerous NuGet packages...but not
Mono.Linq.Expressions.

In the interest of any form of progress, use the "legacy"
`packages.config`-style nuget reference, and see if that changes
anything.

[^0]: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3318737&view=logs&j=cac0e8d3-0ef5-5d2b-b57e-e8fde7204df3&t=b0ec5c6c-f5a1-5ebf-2068-57a5c78a6a85
jonpryor added a commit to jonpryor/xamarin-android that referenced this pull request Dec 20, 2019
Attempting to use `@(PackageReference)` for `Mono.Linq.Expressions`
continues to fail, even after PR dotnet#3995.  Looking at the `msbuild
Xamarin.Android /t:Prepare` output [^0], I see that there is a
`nuget restore Xamarin.Android-Tests.sln`, and it does not always,
and it restores numerous NuGet packages...but not
Mono.Linq.Expressions.

In the interest of any form of progress, use the "legacy"
`packages.config`-style nuget reference, and see if that changes
anything.

[^0]: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3318737&view=logs&j=cac0e8d3-0ef5-5d2b-b57e-e8fde7204df3&t=b0ec5c6c-f5a1-5ebf-2068-57a5c78a6a85
@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.

5 participants