I am working on a PowerShell script intended to be run in Package Manager Console. I am able to add a script at the location returned by $profile in Package Manager Console, but I am not able to get the script to pick up changes without opening a fresh instance of Visual Studio.
According to this article, you should be able to reload the script by typing & $profile:
When you make changes to this user profile while Visual Studio is open Visual Studio will not detect any changes. You can type & $profile in the Package Manager Console to reload the profile.
I can use & $profile to verify my script does not have syntax errors, but it does not load the changes into the console session, which requires me to open a fresh Visual Studio session every time I make a script change.
For example, if I set my profile script to:
function foo{
Write-Output "bar"
}
and then open Visual Studio and Package Manager Console, I can type "foo" at the prompt and get back "bar". If I change "function" to "functionX" and run & $profile, I will get a ParserError in the console. But if I change the script body to Write-Output "baz" and then run & $profile at the console prompt, and I then type foo, I will still get back "bar". The code change is only picked up in a fresh instance of Visual Studio.
Is there a setting in Visual Studio that changes this behavior or a way to force the new script to be loaded?
$profileso it runs in that scope again:. $profile