예제 #1
0
        private void UpdateWorkingDirectory()
        {
            string targetDir;

            if (_solutionManager.IsSolutionOpen)
            {
                targetDir = _solutionManager.SolutionDirectory;
            }
            else
            {
                // if there is no solution open, we set the active directory to be user profile folder
                targetDir = Environment.GetEnvironmentVariable("USERPROFILE");
            }

            if (Runspace.RunspaceAvailability == RunspaceAvailability.Available)
            {
                Runspace.ChangePSDirectory(targetDir);
            }
            else
            {
                // If we are in the middle of executing some other scripts, which triggered the solution to be opened/closed, then we
                // can't execute Set-Location here because of reentrancy policy. So we save the location and change it later when the
                // executing command finishes running.
                _targetDir = targetDir;
                _updateWorkingDirectoryPending = true;
            }
        }
예제 #2
0
 protected void OnExecuteCommandEnd()
 {
     if (_updateWorkingDirectoryPending)
     {
         Runspace.ChangePSDirectory(_targetDir);
         _updateWorkingDirectoryPending = false;
         _targetDir = null;
     }
 }
예제 #3
0
 protected void OnExecuteCommandEnd()
 {
     if (_updateWorkingDirectoryPending)
     {
         Runspace.ChangePSDirectory(_targetDir);
         _updateWorkingDirectoryPending = false;
         _targetDir = null;
     }
     NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageManagerConsoleCommandExecutionEnd);
 }
예제 #4
0
        private void UpdateWorkingDirectory()
        {
            if (Runspace.RunspaceAvailability == RunspaceAvailability.Available)
            {
                // if there is no solution open, we set the active directory to be user profile folder
                string targetDir = _solutionManager.IsSolutionOpen ?
                                   _solutionManager.SolutionDirectory :
                                   Environment.GetEnvironmentVariable("USERPROFILE");

                Runspace.ChangePSDirectory(targetDir);
            }
        }
예제 #5
0
        private void UpdateWorkingDirectory()
        {
            NuGetUIThreadHelper.JoinableTaskFactory.Run(async() =>
            {
                await TaskScheduler.Default;

                if (Runspace.RunspaceAvailability == RunspaceAvailability.Available)
                {
                    // if there is no solution open, we set the active directory to be user profile folder
                    var targetDir = _solutionManager.Value.IsSolutionOpen ?
                                    _solutionManager.Value.SolutionDirectory :
                                    Environment.GetEnvironmentVariable("USERPROFILE");

                    Runspace.ChangePSDirectory(targetDir);
                }
            });
        }