Esempio n. 1
0
        internal void InstallPackage(IPackageRepository repository, Project project, string packageId, SemanticVersion version, bool ignoreDependencies, bool skipAssemblyReferences)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            using (_vsCommonOperations.SaveSolutionExplorerNodeStates(_solutionManager))
            {
                IVsPackageManager packageManager = _packageManagerFactory.CreatePackageManager(repository,
                                                                                               useFallbackForDependencies: false);
                IProjectManager projectManager = packageManager.GetProjectManager(project);

                EventHandler <PackageOperationEventArgs> installedHandler = (sender, e) =>
                {
                    _scriptExecutor.ExecuteInitScript(
                        e.InstallPath, e.Package,
                        NullLogger.Instance);
                };

                EventHandler <PackageOperationEventArgs> addedHandler = (sender, e) =>
                {
                    _scriptExecutor.ExecuteScript(
                        e.InstallPath,
                        PowerShellScripts.Install,
                        e.Package,
                        project,
                        project.GetTargetFrameworkName(),
                        NullLogger.Instance);
                };

                bool oldBindingRedirectValue = packageManager.BindingRedirectEnabled;
                try
                {
                    projectManager.PackageReferenceAdded += addedHandler;
                    packageManager.PackageInstalled      += installedHandler;
                    // if skipping assembly references, disable binding redirects too.
                    packageManager.BindingRedirectEnabled = !skipAssemblyReferences;
                    packageManager.InstallPackage(
                        projectManager,
                        packageId,
                        version,
                        ignoreDependencies,
                        allowPrereleaseVersions: true,
                        skipAssemblyReferences: skipAssemblyReferences,
                        logger: NullLogger.Instance);
                }
                finally
                {
                    packageManager.BindingRedirectEnabled = oldBindingRedirectValue;
                    projectManager.PackageReferenceAdded -= addedHandler;
                    packageManager.PackageInstalled      -= installedHandler;
                }
            }
        }
Esempio n. 2
0
    private bool TryCompile(string source, IScriptExecutor executor, out string errors,
                            out Func <object, Task <object> > invoker)
    {
        invoker = null;
        errors  = null;

        if (source.ToLower().EndsWith(".csx"))
        {
            source = "#load " + Environment.NewLine + source;
        }

        //return the type
        source += "System.Reflection.MethodInfo.GetCurrentMethod().DeclaringType";

        var result = executor.ExecuteScript(source);

        if (result.CompileExceptionInfo != null)
        {
            var scriptException = (ScriptCompilationException)result.CompileExceptionInfo.SourceException;
            errors = scriptException.Message;
            return(false);
        }
        var returnValue = result.ReturnValue;
        var type        = (Type)returnValue;

        invoker = GetInvoker(type);

        errors = null;
        return(true);
    }
Esempio n. 3
0
        internal void InstallPackage(IPackageRepository repository, Project project, string packageId, Version version, bool ignoreDependencies)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            IVsPackageManager packageManager = _packageManagerFactory.CreatePackageManager(repository);
            IProjectManager   projectManager = packageManager.GetProjectManager(project);

            EventHandler <PackageOperationEventArgs> installedHandler = (sender, e) => {
                _scriptExecutor.ExecuteInitScript(e.InstallPath, e.Package, NullLogger.Instance);
            };

            EventHandler <PackageOperationEventArgs> addedHandler = (sender, e) => {
                _scriptExecutor.ExecuteScript(e.InstallPath, PowerShellScripts.Install, e.Package, project, NullLogger.Instance);
            };

            try {
                projectManager.PackageReferenceAdded += addedHandler;
                packageManager.PackageInstalled      += installedHandler;

                packageManager.InstallPackage(projectManager, packageId, version, ignoreDependencies, NullLogger.Instance);
            }
            finally {
                projectManager.PackageReferenceAdded -= addedHandler;
                packageManager.PackageInstalled      -= installedHandler;
            }
        }
Esempio n. 4
0
        public ScriptResult Execute(string script)
        {
            _exec.AddReferences(typeof(Percentage));
            _exec.AddReferenceAndImportNamespaces(new [] { typeof(PackageBuilder), GetType(), typeof(RequiredAttribute) });
            _exec.ImportNamespaces("System.Linq", "CavemanTools");

            _exec.Initialize(new string[0], new IScriptPack[0]);
            return(_exec.ExecuteScript(GetScriptContent(script)));
        }
Esempio n. 5
0
        private int ExecuteSetupElasticSearchScript(string dbIndex)
        {
            var script     = @"../../../Scripts/SetupElasticSearch.ps1";
            var parameters = GetElasticSearchScriptParams(dbIndex);

            powerShellScriptExecutor = new PowerShellScriptExecutor(this, txt_powershellOutput, parameters);
            return(Task.Factory.StartNew(() => powerShellScriptExecutor.ExecuteScript(script)).ContinueWith((r) => {
                return r.Result;
            }).Result);
        }
 private void button2_Click(object sender, EventArgs e)
 {
     configJson["pathToRedis"] = txt_RedisPath.Text;
     Task.Factory.StartNew(() => IsRedisRunning()).ContinueWith((result) =>
     {
         if (result.Result)
         {
             SafeWriteTextBox(txt_powershellOutput, "\n Killing running instance of redis");
             KillRedis();
         }
         string redisFilePathParsed = ParseWindowsPathToBashPath(txt_RdbPath.Text);
         var command = ExtractAndParseBashCommand(redisFilePathParsed);
         Task.Factory.StartNew(() => bashScriptExecutor.ExecuteScript(command)).ContinueWith((r) =>
         {
             ProcessOutput(SafeReadTextBox(txt_powershellOutput));
         }
                                                                                             );
     });
 }
        private int ExecuteGetGitChangesetScript()
        {
            label_GitPleaseWait.Visible   = true;
            progressBar_Changeset.Visible = true;
            var parameters = GetGitChangesetScriptParams();

            powerShellScriptExecutor = new PowerShellScriptExecutor(this, txt_powershellOutput, parameters);
            var script = @"../../../Scripts/GetGitChangeset.ps1";

            return(Task.Factory.StartNew(() => powerShellScriptExecutor.ExecuteScript(script)).ContinueWith((result) => {
                return result.Result;
            }).Result);
        }
        private bool IsRedisRunning()
        {
            bashScriptExecutor = new BashScriptExecutor(txt_powershellOutput);
            bool isRuning = false;

            return(Task.Factory.StartNew(() => bashScriptExecutor.ExecuteScript("-c \"" + "redis-cli ping" + "\"")).ContinueWith((r) =>
            {
                var text = SafeReadTextBox(txt_powershellOutput);
                isRuning = text.Contains("PONG");
            }).ContinueWith((r) =>
            {
                return isRuning;
            }).Result);
        }
Esempio n. 9
0
 private void OnPackageReferenceAdded(object sender, PackageOperationEventArgs e)
 {
     _scriptExecutor.ExecuteScript(e.InstallPath, PowerShellScripts.Install, e.Package, _project, this);
 }
Esempio n. 10
0
 public static void ExecuteInitScript(this IScriptExecutor executor, string installPath, IPackage package, ILogger logger)
 {
     executor.ExecuteScript(installPath, PowerShellScripts.Init, package, null, logger);
 }
        internal void InstallPackage(IPackageRepository repository, Project project, string packageId, SemanticVersion version, bool ignoreDependencies, bool skipAssemblyReferences)
        {
            if (project == null)
            {
                throw new ArgumentNullException("project");
            }

            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            using (_vsCommonOperations.SaveSolutionExplorerNodeStates(_solutionManager))
            {
                IVsPackageManager packageManager = _packageManagerFactory.CreatePackageManager(repository,
                                                                                               useFallbackForDependencies: false);
                IProjectManager projectManager = packageManager.GetProjectManager(project);

                EventHandler <PackageOperationEventArgs> installedHandler = (sender, e) =>
                {
                    _scriptExecutor.ExecuteInitScript(
                        e.InstallPath, e.Package,
                        NullLogger.Instance);
                };

                EventHandler <PackageOperationEventArgs> addedHandler = (sender, e) =>
                {
                    _scriptExecutor.ExecuteScript(
                        e.InstallPath,
                        PowerShellScripts.Install,
                        e.Package,
                        project,
                        project.GetTargetFrameworkName(),
                        NullLogger.Instance);
                };

                bool oldBindingRedirectValue = packageManager.BindingRedirectEnabled;
                try
                {
                    projectManager.PackageReferenceAdded += addedHandler;
                    packageManager.PackageInstalled      += installedHandler;
                    // if skipping assembly references, disable binding redirects too.
                    packageManager.BindingRedirectEnabled = !skipAssemblyReferences;

                    // locate the package to install
                    IPackage package = PackageRepositoryHelper.ResolvePackage(
                        packageManager.SourceRepository,
                        packageManager.LocalRepository,
                        packageId,
                        version,
                        allowPrereleaseVersions: true);

                    if (skipAssemblyReferences)
                    {
                        package = new SkipAssemblyReferencesPackage(package);
                    }

                    // resolve actions
                    var resolver = new ActionResolver()
                    {
                        Logger                  = NullLogger.Instance,
                        DependencyVersion       = packageManager.DependencyVersion,
                        IgnoreDependencies      = ignoreDependencies,
                        AllowPrereleaseVersions = true
                    };
                    resolver.AddOperation(PackageAction.Install, package, projectManager);
                    var actions = resolver.ResolveActions();

                    // execute actions
                    var actionExecutor = new ActionExecutor();
                    actionExecutor.Execute(actions);
                }
                finally
                {
                    packageManager.BindingRedirectEnabled = oldBindingRedirectValue;
                    projectManager.PackageReferenceAdded -= addedHandler;
                    packageManager.PackageInstalled      -= installedHandler;
                }
            }
        }
 public static void ExecuteInitScript(this IScriptExecutor executor, string installPath, IPackage package, ILogger logger)
 {
     executor.ExecuteScript(installPath, PowerShellScripts.Init, package, project: null, targetFramework: null, logger: logger);
 }