예제 #1
0
        public async Task <BuildResult> Build(ProgressMonitor monitor, ConfigurationSelector configuration, bool buildReferencedTargets = false, OperationContext operationContext = null)
        {
            var result = await project.Build(monitor, configuration, buildReferencedTargets, operationContext);

            if (result.Failed)
            {
                return(result);
            }

            // Run the "Pack" target on the project
            var packResult = (await project.RunTarget(monitor, "Pack", configuration, new TargetEvaluationContext(operationContext))).BuildResult;

            return(result.Append(packResult));
        }
예제 #2
0
        private async Task <bool> UpdateInternal()
        {
            using (var monitor = IdeApp.Workbench.ProgressMonitors.GetToolOutputProgressMonitor(false))
            {
                monitor.BeginTask(1);

                try
                {
                    var solution = IdeApp.Workspace.CurrentSelectedSolution;

                    if (solution == null)
                    {
                        return(false);
                    }

                    DotNetProject reactorUIProject = null;

                    foreach (var project in solution.GetAllProjects()
                             .OfType <DotNetProject>()
                             .Where(_ => _.TargetFramework.Id.Identifier == ".NETStandard"))
                    {
                        var packages = await project.GetPackageDependencies(ConfigurationSelector.Default, CancellationToken.None);

                        if (packages.Any(_ => _.Name == "XamarinReactorUI") && packages.Any(_ => _.Name == "XamarinReactorUI.HotReload"))
                        {
                            reactorUIProject = project;
                            break;
                        }
                    }

                    if (reactorUIProject == null)
                    {
                        await monitor.Log.WriteLineAsync("Solution doesn't contain a Xamarin Forms project referencing BOTH XamarinReactorUI and XamarinReactorUI.HotReload");

                        return(false);
                    }

                    var startupProject = solution.StartupItem as DotNetProject;

                    if (startupProject == null)
                    {
                        await monitor.Log.WriteLineAsync("Solution hasn't a valid startup project");

                        return(false);
                    }

                    OS os = OS.None;
                    if (startupProject.TargetFramework.Id.Identifier == "Xamarin.iOS")
                    {
                        os = OS.iOS;
                    }
                    else if (startupProject.TargetFramework.Id.Identifier == "MonoAndroid")
                    {
                        os = OS.Android;
                    }

                    if (os == OS.None)
                    {
                        await monitor.Log.WriteLineAsync($"Unable to find an valid Xamarin Android or iOS project in the solution");

                        return(false);
                    }

                    IdeApp.Workbench.SaveAll();

                    var buildResult = await reactorUIProject.Build(monitor, ConfigurationSelector.Default);

                    if (buildResult.Failed)
                    {
                        return(false);
                    }

                    if (os == OS.Android)
                    {
                        if (!ExecutePortForwardCommmand(monitor))
                        {
                            return(false);
                        }
                    }

                    if (!await SendAssemblyToEmulatorAsync(monitor, reactorUIProject.GetOutputFileName(ConfigurationSelector.Default).FullPath, true))
                    {
                        return(false);
                    }

                    return(true);
                }
                finally
                {
                    monitor.EndTask();
                }
            }
        }