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; } }
protected void OnExecuteCommandEnd() { if (_updateWorkingDirectoryPending) { Runspace.ChangePSDirectory(_targetDir); _updateWorkingDirectoryPending = false; _targetDir = null; } }
protected void OnExecuteCommandEnd() { if (_updateWorkingDirectoryPending) { Runspace.ChangePSDirectory(_targetDir); _updateWorkingDirectoryPending = false; _targetDir = null; } NuGetEventTrigger.Instance.TriggerEvent(NuGetEvent.PackageManagerConsoleCommandExecutionEnd); }
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); } }
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); } }); }