xamarin-macios/msbuild/tests/MyXamarinFormsApp/AppDelegate.cs

32 строки
1008 B
C#
Исходник Обычный вид История

[xibuild] support for SDK-style projects & Xamarin.Forms test (#6461) Context: https://github.com/microsoft/msbuild/blob/4ecedac7339f22f51c783c67ee1ba427cb870fa8/src/Shared/BuildEnvironmentHelper.cs#L567-L586 Context: https://github.com/xamarin/xamarin-android/tree/1d71d998376f60b75510304f1d8a7925f3f3406f/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 20:20:32 +03:00
using System;
using System.Collections.Generic;
using System.Linq;
using Foundation;
using UIKit;
namespace MyXamarinFormsApp.iOS
{
// The UIApplicationDelegate for the application. This class is responsible for launching the
// User Interface of the application, as well as listening (and optionally responding) to
// application events from iOS.
[Register ("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
//
// This method is invoked when the application has loaded and is ready to run. In this
// method you should instantiate the window, load the UI into it and then make the window
// visible.
//
// You have 17 seconds to return from this method, or iOS will terminate your application.
//
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init ();
LoadApplication (new App ());
return base.FinishedLaunching (app, options);
}
}
}