Exemple #1
0
        public async override Task RunAsync()
        {
            if (CommandChecker.CommandExists("dotnet"))
            {
                var extensionsProj = await ExtensionsHelper.EnsureExtensionsProjectExistsAsync();

                var args = $"add {extensionsProj} package {Package} --version {Version}";
                if (!string.IsNullOrEmpty(Source))
                {
                    args += $" --source {Source}";
                }

                var addPackage = new Executable("dotnet", args);
                await addPackage.RunAsync(output => ColoredConsole.WriteLine(output), error => ColoredConsole.WriteLine(ErrorColor(error)));

                var syncAction = new SyncExtensionsAction()
                {
                    OutputPath = OutputPath
                };

                await syncAction.RunAsync();
            }
            else
            {
                ColoredConsole.Error.WriteLine(ErrorColor("Extensions command require dotnet on your path. Please make sure to install dotnet for your system from https://www.microsoft.com/net/download"));
            }
        }
        public async override Task RunAsync()
        {
            if (CommandChecker.CommandExists("dotnet"))
            {
                if (!string.IsNullOrEmpty(ConfigPath) && !FileSystemHelpers.DirectoryExists(ConfigPath))
                {
                    throw new CliArgumentsException("Invalid config path, please verify directory exists");
                }

                var extensionsProj = await ExtensionsHelper.EnsureExtensionsProjectExistsAsync(_secretsManager, Csx, ConfigPath);

                if (string.IsNullOrEmpty(Package) && string.IsNullOrEmpty(Version))
                {
                    var project = ProjectHelpers.GetProject(extensionsProj);
                    foreach (var extensionPackage in ExtensionsHelper.GetExtensionPackages())
                    {
                        // Only add / update package referece if it does not exist or forced update is enabled
                        if (!ProjectHelpers.PackageReferenceExists(project, extensionPackage.Name) || Force)
                        {
                            await AddPackage(extensionsProj, extensionPackage.Name, extensionPackage.Version);
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(Package) && !string.IsNullOrEmpty(Version))
                {
                    await AddPackage(extensionsProj, Package, Version);
                }
                else
                {
                    throw new CliArgumentsException("Must specify extension package name and version",
                                                    new CliArgument {
                        Name = nameof(Package), Description = "Extension package name"
                    },
                                                    new CliArgument {
                        Name = nameof(Version), Description = "Extension package version"
                    }
                                                    );
                }

                var syncAction = new SyncExtensionsAction(_secretsManager)
                {
                    OutputPath = OutputPath,
                    ConfigPath = ConfigPath
                };

                await syncAction.RunAsync();
            }
            else
            {
                ColoredConsole.Error.WriteLine(ErrorColor(Constants.Errors.ExtensionsNeedDotnet));
            }
        }
Exemple #3
0
        public async override Task RunAsync()
        {
            var extensionsProj = await ExtensionsHelper.EnsureExtensionsProjectExistsAsync();

            var addPackage = new Executable("dotnet", $"add {extensionsProj} package {Package} --version {Version}");
            await addPackage.RunAsync(output => ColoredConsole.WriteLine(output), error => ColoredConsole.WriteLine(ErrorColor(error)));

            var syncAction = new SyncExtensionsAction()
            {
                OutputPath = OutputPath
            };

            await syncAction.RunAsync();
        }
Exemple #4
0
        public async override Task RunAsync()
        {
            if (CommandChecker.CommandExists("dotnet"))
            {
                if (!string.IsNullOrEmpty(ConfigPath) && !FileSystemHelpers.DirectoryExists(ConfigPath))
                {
                    throw new CliArgumentsException("Invalid config path, please verify directory exists");
                }

                var extensionsProj = await ExtensionsHelper.EnsureExtensionsProjectExistsAsync(_secretsManager, Csx, ConfigPath);

                if (string.IsNullOrEmpty(Package) && string.IsNullOrEmpty(Version))
                {
                    foreach (var extensionPackage in ExtensionsHelper.GetExtensionPackages())
                    {
                        await AddPackage(extensionsProj, extensionPackage.Name, extensionPackage.Version);
                    }
                }
                else if (!string.IsNullOrEmpty(Package) && !string.IsNullOrEmpty(Version))
                {
                    await AddPackage(extensionsProj, Package, Version);
                }
                else
                {
                    throw new CliArgumentsException("Must specify extension package name and version",
                                                    new CliArgument {
                        Name = nameof(Package), Description = "Extension package name"
                    },
                                                    new CliArgument {
                        Name = nameof(Version), Description = "Extension package version"
                    }
                                                    );
                }

                var syncAction = new SyncExtensionsAction(_secretsManager)
                {
                    OutputPath = OutputPath,
                    ConfigPath = ConfigPath
                };

                await syncAction.RunAsync();
            }
            else
            {
                ColoredConsole.Error.WriteLine(ErrorColor("Extensions command require dotnet on your path. Please make sure to install dotnet for your system from https://www.microsoft.com/net/download"));
            }
        }
        public async override Task RunAsync()
        {
            var extensionsProj = await ExtensionsHelper.EnsureExtensionsProjectExistsAsync();

            var args = $"add {extensionsProj} package {Package} --version {Version}";

            if (!string.IsNullOrEmpty(Source))
            {
                args += $" --source {Source}";
            }

            var addPackage = new Executable("dotnet", args);
            await addPackage.RunAsync(output => ColoredConsole.WriteLine(output), error => ColoredConsole.WriteLine(ErrorColor(error)));

            var syncAction = new SyncExtensionsAction()
            {
                OutputPath = OutputPath
            };

            await syncAction.RunAsync();
        }
        public async override Task RunAsync()
        {
            var extensionBundleManager = ExtensionBundleHelper.GetExtensionBundleManager();

            if (extensionBundleManager.IsExtensionBundleConfigured())
            {
                var hostFilePath = Path.Combine(Environment.CurrentDirectory, ScriptConstants.HostMetadataFileName);
                if (_showNoActionWarning)
                {
                    ColoredConsole.WriteLine(WarningColor($"No action performed. Extension bundle is configured in {hostFilePath}."));
                }
                return;
            }

            if (!string.IsNullOrEmpty(ConfigPath) && !FileSystemHelpers.DirectoryExists(ConfigPath))
            {
                throw new CliArgumentsException("Invalid config path, please verify directory exists");
            }

            if (!NeedsExtensionsInstall())
            {
                return;
            }

            if (CommandChecker.CommandExists("dotnet"))
            {
                var extensionsProj = await ExtensionsHelper.EnsureExtensionsProjectExistsAsync(_secretsManager, Csx, ConfigPath);

                if (string.IsNullOrEmpty(Package) && string.IsNullOrEmpty(Version))
                {
                    var project = ProjectHelpers.GetProject(extensionsProj);
                    foreach (var extensionPackage in ExtensionsHelper.GetExtensionPackages())
                    {
                        // Only add / update package referece if it does not exist or forced update is enabled
                        if (!ProjectHelpers.PackageReferenceExists(project, extensionPackage.Name) || Force)
                        {
                            await AddPackage(extensionsProj, extensionPackage.Name, extensionPackage.Version);
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(Package) && !string.IsNullOrEmpty(Version))
                {
                    await AddPackage(extensionsProj, Package, Version);
                }
                else
                {
                    throw new CliArgumentsException("Must specify extension package name and version",
                                                    new CliArgument {
                        Name = nameof(Package), Description = "Extension package name"
                    },
                                                    new CliArgument {
                        Name = nameof(Version), Description = "Extension package version"
                    }
                                                    );
                }

                var syncAction = new SyncExtensionsAction(_secretsManager, false)
                {
                    OutputPath = OutputPath,
                    ConfigPath = ConfigPath
                };

                await syncAction.RunAsync();
            }
            else
            {
                throw new CliException(Constants.Errors.ExtensionsNeedDotnet);
            }
        }