microsoft / windows-dev-box-setup-scripts

Scripts to simplify setting up a Windows developer box
MIT License
1.5k stars 367 forks source link

New: Install VS Code debugger extensions #48

Closed molant closed 6 years ago

molant commented 6 years ago

Install automatically VS Code debugger extensions for Chrome an Edge


Ref: #46

yodurr commented 6 years ago

love it, thanks!

crutkas commented 6 years ago

why do you need to refreshenv?

molant commented 6 years ago

@gep13 can say more, but I believe it's because code will not be in the path after doing choco install -y vscode and it is required in order to install the extensions.

See https://github.com/Microsoft/windows-dev-box-setup-scripts/pull/48#discussion_r195328690

gep13 commented 6 years ago

That is what I suspect it required yes. I ran into this during a demo I was given.

Also, here in this package:

https://chocolatey.org/packages/vscode-powershell

A refresh is required, or at least, it was.

crutkas commented 6 years ago

One Thought, just have choco vs code and the vs packages to refresh. Where does one submit a PR for those?

gep13 commented 6 years ago

@crutkas said... One Thought, just have choco vs code and the vs packages to refresh. Where does one submit a PR for those?

I am not sure that I follow your train of thought here. Can you please elaborate?

crutkas commented 6 years ago

sorry, if we need to do a refresh for the environment, wouldn't the better spot to do the adjustment is actually in the choco package? that way everyone gets the update versus only someone that uses our scripts

ferventcoder commented 6 years ago

sorry, if we need to do a refresh for the environment, wouldn't the better spot to do the adjustment is actually in the choco package? that way everyone gets the update versus only someone that uses our scripts

@crutkas unfortunately Windows doesn't quite work that nicely. Even if those packages call Update-SessionEnvironment (aka refreshenv for PowerShell.exe), it won't matter once the choco.exe process exits and it moves back up to the powershell.exe process. A subprocess can update the environment variables all it wants in that process, and when it exits, the parent process won't see the changes. If it makes permanent changes to User/System environment variables, that also won't be seen in command shells until the shell is closed and reopened.

Chocolatey however has a concept of refreshenv, that will review the changes in the registry and update the process environment variables with the changes. There is refreshenv.cmd for cmd.exe command shells, and there is Update-SessionEnvironment, which is aliased to refreshenv when the Chocolatey PowerShell profile is installed. As you can guess, running refreshenv in PowerShell without that profile loaded, it's going to call refreshenv.cmd, starting a cmd.exe subprocess, updating those environment variables in that subprocess, and then exiting and having no changes to the current PowerShell.exe command shell.

Does all of that make sense?

molant commented 6 years ago

@ferventcoder so if I've understood correctly I have to replace refreshenv with Update-SessionEnvironment in this PR?

gep13 commented 6 years ago

@molant since everything here is running in PowerShell, yes, that would be the safest thing to do.