コード例 #1
0
ファイル: Delete.cs プロジェクト: cwensley/xamarin-macios
        public override bool Execute()
        {
            var result = base.Execute();

            if (!this.ShouldExecuteRemotely(SessionId))
            {
                return(result);
            }

            var client = BuildConnection
                         .GetAsync(SessionId, BuildEngine4)
                         .Result
                         .Client;

            if (!client.IsConnected)
            {
                return(result);
            }

            foreach (var file in Files)
            {
                client.DeleteFileAsync(file.ItemSpec).Wait();
            }

            return(result);
        }
コード例 #2
0
ファイル: Exec.cs プロジェクト: cwensley/xamarin-macios
        async Task <bool> RunSudoCommandAsync()
        {
            try {
                var client = BuildConnection
                             .GetAsync(SessionId, BuildEngine4)
                             .Result
                             .Client;
                var sshCommands = client
                                  .MessagingService
                                  .Ssh
                                  .Commands;
                var commandOutput = await sshCommands
                                    .RunSudoCommandAsync(Command, ServerPassword.ToSecureString())
                                    .ConfigureAwait(continueOnCapturedContext: false);

                await commandOutput.Do(output => {
                    if (ConsoleToMSBuild && !string.IsNullOrEmpty(output))
                    {
                        Log.LogMessage(output);
                    }
                });

                return(true);
            } catch (Exception ex) {
                Log.LogErrorFromException(ex, showStackTrace: true, showDetail: true, file: null);

                return(false);
            }
        }
コード例 #3
0
        public override bool Execute()
        {
            var result = base.Execute();

            if (!this.ShouldExecuteRemotely(SessionId))
            {
                return(result);
            }

            var client = BuildConnection
                         .GetAsync(SessionId, BuildEngine4)
                         .Result
                         .Client;

            if (!client.IsConnected)
            {
                return(result);
            }

            foreach (var directory in Directories)
            {
                client.DeleteDirectoryAsync(directory.ItemSpec).Wait();
            }

            if (RemoveAppDir)
            {
                client.DeleteAppDirectoryAsync().Wait();
            }

            return(result);
        }
コード例 #4
0
        async System.Threading.Tasks.Task <IBuildClient> GetBuildClientAsync()
        {
            var connection = await BuildConnection
                             .GetAsync(SessionId, BuildEngine4)
                             .ConfigureAwait(continueOnCapturedContext: false);

            return(connection.Client);
        }
コード例 #5
0
        async Threading.Task <bool> ExecuteAsync()
        {
            try {
                var connection = await BuildConnection.GetAsync(SessionId, BuildEngine4).ConfigureAwait(continueOnCapturedContext: false);

                var buildClient = connection.Client as BuildClient;

                if (!connection.IsConnected || buildClient == null)
                {
                    Log.LogWarning(MSBStrings.E0179, nameof(VerifyXcodeVersion));

                    return(true);
                }

                var xcodeVerificationResult = await buildClient
                                              .RunMessagingAsync <VerifyXcodeVersionMessage, VerifyXcodeVersionResult> (new VerifyXcodeVersionMessage())
                                              .ConfigureAwait(continueOnCapturedContext: false);

                if (!xcodeVerificationResult.IsCompatibleVersion)
                {
                    if (string.IsNullOrEmpty(xcodeVerificationResult.XcodeVersion) || string.IsNullOrEmpty(xcodeVerificationResult.RecommendedXcodeVersion))
                    {
                        Log.LogWarning(MSBStrings.E0183);
                    }
                    else
                    {
                        Log.LogWarning(MSBStrings.E0184, xcodeVerificationResult.XcodeVersion, xcodeVerificationResult.RecommendedXcodeVersion);
                    }
                }

                return(true);
            } catch (Exception ex) {
                Log.LogWarning(MSBStrings.E0185, ex.Message);

                return(true);
            }
        }
コード例 #6
0
        public override bool Execute()
        {
            try {
                LogTaskProperty("ImageAssets", ImageAssets);
                LogTaskProperty("ProjectDir", ProjectDir);
                LogTaskProperty("SessionId", SessionId);

                var connection  = BuildConnection.GetAsync(SessionId, BuildEngine4).Result;
                var buildClient = connection.Client as BuildClient;

                if (!connection.IsConnected || buildClient == null)
                {
                    Log.LogWarning(MSBStrings.E0179, nameof(ResolveUniversalTypeIdentifiers));

                    return(true);
                }

                var contentFiles = ImageAssets
                                   .Where(asset => Path.GetFileName(asset.ItemSpec) == "Contents.json" &&
                                          Path.GetDirectoryName(asset.ItemSpec).EndsWith(".dataset"))
                                   .Select(x => x.ItemSpec);

                foreach (var filePath in contentFiles)
                {
                    string  content;
                    DataSet dataset = null;

                    if (File.Exists(filePath))
                    {
                        content = File.ReadAllText(filePath);
                        dataset = JsonConvert.DeserializeObject <DataSet> (content);
                    }

                    if (dataset == null)
                    {
                        Log.LogError(MSBStrings.E0180, Path.GetDirectoryName(filePath));
                        continue;
                    }

                    var dataItemsToComplete = dataset
                                              .DataItems
                                              .Where(item => string.IsNullOrEmpty(item.UniversalTypeIdentifier) &&
                                                     !string.IsNullOrEmpty(item.Filename)).ToList();

                    foreach (var data in dataItemsToComplete)
                    {
                        var file = ImageAssets.FirstOrDefault(x => Path.GetFileName(x.ItemSpec) == data.Filename);

                        if (file == null)
                        {
                            Log.LogWarning(MSBStrings.E0181, data.Filename);

                            continue;
                        }

                        var message = new GetUniversalTypeIdentifierMessage {
                            Payload  = File.ReadAllBytes(file.ItemSpec),
                            FileName = Path.GetFileName(data.Filename)
                        };

                        var response = buildClient
                                       .RunMessagingAsync <GetUniversalTypeIdentifierMessage, GetUniversalTypeIdentifierResult> (message, timeoutSecs: 10)
                                       .Result;

                        if (string.IsNullOrEmpty(response.UniversalTypeIdentifier))
                        {
                            Log.LogError(string.Format(MSBStrings.E0182, data.Filename, Path.GetDirectoryName(filePath)));
                        }

                        data.UniversalTypeIdentifier = response.UniversalTypeIdentifier;
                    }

                    if (dataItemsToComplete.Any())
                    {
                        content = JsonConvert.SerializeObject(dataset, Formatting.Indented);
                        File.WriteAllText(filePath, content);
                    }
                }

                return(!Log.HasLoggedErrors);
            } catch (Exception ex) {
                Log.LogErrorFromException(ex);

                return(false);
            }
        }