xamarin-macios/msbuild/tests/MyXamarinFormsApp
Jonathan Peppers a51e9f8e88
[xibuild] support for SDK-style projects & Xamarin.Forms test (#6461)
Context: 4ecedac733/src/Shared/BuildEnvironmentHelper.cs (L567-L586)
Context: 1d71d99837/tools/xabuild

When using `xibuild` to build an SDK-style project:

    tools/xibuild/xibuild -- msbuild/tests/MyXamarinFormsApp/MyXamarinFormsAppNS/MyXamarinFormsAppNS.csproj /restore

It was failing with:

    Resolving SDK 'Microsoft.NET.Sdk'...
    Project "msbuild/tests/MyXamarinFormsApp/MyXamarinFormsApp.csproj" is building "msbuild/tests/MyXamarinFormsApp/MyXamarinFormsAppNS/MyXamarinFormsAppNS.csproj" (GetTargetFrameworks target(s)):
    Building with tools version "Current".
    msbuild/tests/MyXamarinFormsApp/MyXamarinFormsAppNS/MyXamarinFormsAppNS.csproj : error MSB4236: The SDK 'Microsoft.NET.Sdk' specified could not be found.

Looking at this code, it looks pretty familiar -- it came from xabuild!

xibuild was currently setting `MSBuildSDKsPath` via a config file:

    <msbuildToolsets default="Current">
      <toolset toolsVersion="Current">
        <property name="MSBuildSDKsPath" value="/Library/Frameworks/Mono.framework/Versions/Current/lib/mono/msbuild/Current/bin/Sdks" />

Reviewing the source code for MSBuild, they don't even look for this
value via MSBuild properties... They just look for Visual Studio
directories and a `MSBuildSDKsPath` environment variable. We don't have
to use this in Xamarin.Android, because we do things a different way.
There was craziness involved to get both Windows & Mac working.

For this to work on Mac, we can just set `MSBuildSDKsPath` when
starting the new MSBuild process.

I cleaned up how `MSBUILD_EXE_PATH` is set so both of these variables
are just set via `ProcessStartInfo.EnvironmentVariables`.

Now I can fully build a Xamarin.Forms project that references a
netstandard library with `xibuild`:

    $ tools/xibuild/xibuild -- msbuild/tests/MyXamarinFormsApp/MyXamarinFormsApp.csproj /restore
    ...
    Build succeeded.
        0 Warning(s)
        0 Error(s)
    Time Elapsed 00:00:15.83

~~ New Tests ~~

I went ahead and added a new Xamarin.Forms project to test and verify
that it builds. It is the Blank Forms app template from latest VS4Mac.

With the changes to `xibuild`, I was able to build with the in-process
MSBuild APIs.
2019-07-01 12:20:32 -05:00
..
Assets.xcassets/AppIcon.appiconset [xibuild] support for SDK-style projects & Xamarin.Forms test (#6461) 2019-07-01 12:20:32 -05:00
MyXamarinFormsAppNS [xibuild] support for SDK-style projects & Xamarin.Forms test (#6461) 2019-07-01 12:20:32 -05:00
Properties [xibuild] support for SDK-style projects & Xamarin.Forms test (#6461) 2019-07-01 12:20:32 -05:00
Resources [xibuild] support for SDK-style projects & Xamarin.Forms test (#6461) 2019-07-01 12:20:32 -05:00
AppDelegate.cs [xibuild] support for SDK-style projects & Xamarin.Forms test (#6461) 2019-07-01 12:20:32 -05:00
Entitlements.plist [xibuild] support for SDK-style projects & Xamarin.Forms test (#6461) 2019-07-01 12:20:32 -05:00
Info.plist [xibuild] support for SDK-style projects & Xamarin.Forms test (#6461) 2019-07-01 12:20:32 -05:00
Main.cs [xibuild] support for SDK-style projects & Xamarin.Forms test (#6461) 2019-07-01 12:20:32 -05:00
MyXamarinFormsApp.csproj [xibuild] support for SDK-style projects & Xamarin.Forms test (#6461) 2019-07-01 12:20:32 -05:00