Powershell: Debugging and IntelliSense in VS Code don't work

Created on 17 Mar 2017  路  23Comments  路  Source: PowerShell/PowerShell

[x] - After update to "C# for Visual Studio Code 1.8.0" debugging don't work.

The system cannot find the file specified

[x] - IntelliSense don't work in VS Code after migrating to MSBuild (json -> csproj).

Issue-Question Resolution-External Resolution-Fixed

Most helpful comment

I have posted a new release of the C# extension that includes the fix.

To try it -- use the use the Installing Beta Releases instructions to install v1.9.0-beta2.

All 23 comments

Still working for me with C# plugin 1.8.0 and VSCode 1.10.2 on Ubuntu16. You may need to follow-up with https://github.com/OmniSharp/omnisharp-vscode

I've been seeing something similar to this as well: https://github.com/OmniSharp/omnisharp-vscode/issues/1272. I have much better luck launching PowerShell from code than attaching to a process, I can get it to work occasionally. Hopefully this is fixed soon with OmniSharp.

I just attempted to reproduce on Mac OS X Sierra, with VSCode 1.10.2, and am unable to reproduce the reported behavior successfully.

Perhaps there's a cache folder somewhere that's affecting you? Can you use Sysinternals tools to see which file is being accessed?

Cheers,
Trevor Sullivan

I'm seeing this on Windows in VS Code 1.10.2 with C# add-in 1.8.0.

I am able to start PowerShell by hand then attach, but I cannot start PS from VS Code.

CC @daviwil

I already thought that I only work on Windows 馃槃 @jeffbi 鉁岋笍

Work around: Add .exe to the end of program in .vscode/launch.json:

...
            "program": "${workspaceRoot}/debug/powershell.exe",
...

Outstanding. Worked for me. Thank you.

@jeffbi After migration to MSBuild the IntelliSense in VS Code stopped working because now there are no json files. Could you solve this?

@iSazonov known limitation with .csproj and vscode https://github.com/OmniSharp/omnisharp-vscode/issues/1156

Yes, thanks! I download SLN file from @powercode - it is work well. But we need fix.

I have posted a new release of the C# extension that includes the fix.

To try it -- use the use the Installing Beta Releases instructions to install v1.9.0-beta2.

@iSazonov I'm not quite sure what you're asking me for. I can confirm that Intellisense in VS Code is no longer working.

Well, it worked once. Now I'm unable to build in VS Code at all. I consistently get this:
```
VERBOSE: Using configuration 'Debug'
VERBOSE: Top project directory is
C:\Users\jeffbi\Clients\Microsoft\GitHub\PowerShell\src\powershell-win-core
VERBOSE: Using framework 'netcoreapp1.1'
VERBOSE: Using runtime 'win10-x64'
Run dotnet restore
warn : The folder 'C:\Users\jeffbi\Clients\Microsoft\GitHub\PowerShell\src\powershell-win-core' does not contain a project to restore.
warn : The folder 'C:\Users\jeffbi\Clients\Microsoft\GitHub\PowerShell\src\TypeCatalogGen' does not contain a project to restore.
warn : The folder 'C:\Users\jeffbi\Clients\Microsoft\GitHub\PowerShell\src\ResGen' does not contain a project to restore.
warn : The folder 'C:\Users\jeffbi\Clients\Microsoft\GitHub\PowerShell\test\csharp' does not contain a project to restore.
warn : The folder 'C:\Users\jeffbi\Clients\Microsoft\GitHub\PowerShell\test\PSReadLine' does not contain a project to restore.
warn : The folder 'C:\Users\jeffbi\Clients\Microsoft\GitHub\PowerShell\test\tools\CreateChildProcess' does not contain a project to restore.
warn : The folder 'C:\Users\jeffbi\Clients\Microsoft\GitHub\PowerShell\test\tools\EchoArgs' does not contain a project to restore.
Run ResGen (generating C# bindings for resx files)
The current project is not valid because of the following errors:
C:\Users\jeffbi\Clients\Microsoft\GitHub\PowerShell\src\ResGen(1,0): error DOTNET1017: Project file does not exist 'C:\Users\jeffbi\Clients\Microsoft\GitHub\PowerShell\src\ResGen\project.json'.
Execution of { dotnet run } failed with exit code 1
At C:\Users\jeffbi\Clients\Microsoft\GitHub\PowerShell\build.psm1:2359 char:13

  • throw "Execution of {$sb} failed with exit code $LASTEXIT ...
  • ~~~~~~~~~~~~~

    • CategoryInfo : OperationStopped: (Execution of { ...ith exit co

      de 1:String) [], RuntimeException

    • FullyQualifiedErrorId : Execution of { dotnet run } failed with exit cod

      e 1

      ```

      I get this both with the current C# extension and with the beta @gregg-miskelly referred to.

I've tried several things including killing off and re-cloning all my local repositories, to no avail.

Building inside PowerShell with Start-PSBuild works fine.

I'm also able to build in VS Code in Linux, still using the 1.8.0 version of the C# plugin.

@jeffbi this doesn't have anything to do with VS Code or the C# extension. All VS Code does is kick off command line build script. My fix was just about fixing launch to work without the '.exe' suffix in program.

At any rate -- I could be wrong, but it sounds like you might have a post-preview-2 .NET CLI installed, and, at least when I briefly played with the PowerShell repo, it was still using project.json based projects. If so - those two things will not play well together. The real fix would be to update the PowerShell repo to .csproj. The hack is to fix the powershell build scripts so that instead of running dotnet build (for example) instead run dotnet <path-to-preview2-dotnet.dll> build. You are also supposed to be able to lay down a global.json to make this work, but I never had any luck with that. But maybe the .NET CLI folks fixed that before RTW.

@gregg-miskelly we've converted PowerShell repo to .csproj from project.json files. I've also noticed that I can build from start-psbuild which calls dotnet directly while in vscode it errors out. I would suggest uninstalling all dotnet and rerunning start-psbootstrap to get the appropriate version installed

Got rid of dotnet and reran start-psbootstrap. All seems to be working now.

I'm using the 1.9.0-beta2 version of the C# extension, and debugging is working well also.

Thanks to both of you.

@jeffbi You can use sln file from @powercode #3400 to revive IntelliSense in VS Code.

We really need sln file in repo root folder to get IntelliSense work properly.

@iSazonov submit SLN as PR?

Yes.

VS 2017 sln was added in PR #4748

Was this page helpful?
0 / 5 - 0 ratings