NuGet / Home

Repo for NuGet Client issues
Other
1.5k stars 253 forks source link

PMC hides console windows which affects child processes of VS #9694

Open johnendev opened 4 years ago

johnendev commented 4 years ago

Details about Problem

NuGet product used: Package Manager Console VS version: 16.6.2 OS version: win10 1909 18363.900

Worked before? No, this has always been broken for long as I can remember.

Repro steps

  1. Open VS and open Package Manager Console. Make sure you don't load any custom PowerShell profile in PMC.
  2. From VS, all of the following will show a console window a. start a debug session of a .net framework console app b. start a debug session of a dotnet core console app c. start Developer Command Prompt from tools meny d. start Developer PowerShell from tools menu c. run "Open Command Prompt" from the "Power Commands" extension
  3. In PMC, invoke any command which results in executing a console programe, e.g. cmd /c echo test
  4. Now try any of the items from step 2, all are broken and don't show a console window.

Calling the following PInvoke function in PMC unblocks new console windows created after that, until another console command is invoked in PMC.

[DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
public static extern bool FreeConsole();

Since git is called from my prompt function that means every time I run anything. Of course one can work around this issue by freeing the console at the end of the PowerShell prompt function. It would be better if PMC did this automatically, allocating the console (if needed) and hiding it at the start of a command and freeing it again at the end after the prompt has been invoked. PMC should be able to do this since it is already aware of when a command starts/ends and disables/enables menus etc in VS.

donnie-msft commented 4 years ago

//cc @dominoFire