Can't debug anymore NET Core in Visual Studio

2019-06-13 03:56发布

问题:

I am experiencing a problem like the one exposed in this SO question:

Unable to start program "C:\Program Files\dotnet\dotnet.exe"

I am asking this question not to create a duplicate but to provide more info and because the problem started only after the day I installed Python from its main website, Python Tools from Microsoft and Anaconda from Continuum. I'd bet the Anaconda is the guilty.

When I create any .NET Core project, be it console or web, and I attempt to debug it in Visual Studio 2015 I get this error:

I did the Python installations both on a Windows 7 SP1 pc and on a Windows 10 pc. Until then I was able to create, compile and debug a Net Core project in Visual Studio 2015 without any problem. When I started VS 2015 a couple of days after the Python installations, both my computers had the problem.

It's not a problem of Net Core, it is a Visual Studio 2015 problem. I am sure because if I build and run from CLI or if I debug using Visual Studio Code everything works as expected, the problem only affects Visual Studio 2015 Community.

Following several posts on the subject I have tried different proposed solutions, without success:

  • Rebooted infinite times both Windows 7 and Windows 10.
  • Reset Visual Studio Settings.
  • Deleted project.json and lock file I deleted the .vs folder.
  • Repaired .Net Core.
  • Repaired VS 2015.
  • Uninstalled Python, Python tools, Anaconda.
  • Uninstalled / reinstalled Visual Studio 2015 and Net Core Tools for VS several times.
  • Uninstalled and reinstalled the VC++ redistributable, x86 and x64.
  • Tried to run VS in normal mode and as administrator.
  • Forced to run dotnet.exe as administrator.
  • Created new HelloWorld projects from scratch.
  • Opened projects created with Visual Studio Code that can be debugged without any error in Visual Studio Code.
  • Redone the login.
  • Used VS 2015 without login.
  • Selected in Debug Options: Use Managed Compatibily Mode
  • Selected in Debug Options: Use Native Compatibility Mode
  • Selected in Debug Options both the Options

The problem appears when I start the debug with the "play button" or when I select Debug-> Start Debugging (F5). The code compiles without errors then the message box appears when the app, even a simple "Hello World", should start.

  • Options are set to Debug/Any Cpu.
  • The file dotnet.exe is in its folder as expected.
  • If I use Process Monitor I can see the process dotnet.exe is created with success as child of devenv.exe and then immediately exited, with 0.0000 user time and kernel time.

If I select Debug -> Start Without Debugging (CTRL+F5) the code runs without problems.

If I select Debug -> Attach To Process -> dotnet.exe [type Managed (Core CLR), x64], default transport I get the error: "Unable to attachto the process. No more data is available"

Any hint to solve this without formatting the disk and reinstalling from scratch Windows?

Edit:

This is the project.json for a new created solution, a standard "Hello World":

{
  "version": "1.0.0-*",
  "buildOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.NETCore.App": {
      "type": "platform",
      "version": "1.0.1"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": "dnxcore50"
    }
  }
}

The "Path" value in Environment Variables, for "all users" is:

%SystemRoot%\system32;
%SystemRoot%;
%SystemRoot%\System32\Wbem;
%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;
C:\Program Files\Intel\WiFi\bin\;
C:\Program Files\Common Files\Intel\WirelessCommon\;
C:\blp\API;C:\blp\API\dde;
C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;
C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;
C:\Program Files (x86)\Skype\Phone\;
C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;
C:\Program Files\Microsoft DNX\Dnvm\;
C:\Program Files\dotnet\;
C:\Program Files\Git\cmd

For my user only is:

C:\blp\DAPI;
C:\blp\DAPI\DDE;
C:\Program Files (x86)\Microsoft VS Code\bin