2015-06-09 17 views
20

Ich möchte einen neuen Editor von Microsoft - Visual Studio Code ausprobieren. Ich möchte eine einfache App (wie Hallo, Welt) implementieren und in der Lage sein, es zu debuggen. Aber nach vielem Googeln und Versuchen habe ich es nicht geschafft. Ist das möglich? Ich habe Windows 10 mit Visual Studio 2015 installiert.Visual Studio Code, C# Unterstützung unter Windows

Was ich versucht habe zu tun:

1) Kommentar- der folgenden in der tasks.json Datei:

{ 
"version": "0.1.0", 
"command": "msbuild", 
"args": [ 
    // Ask msbuild to generate full paths for file names. 
    "/property:GenerateFullPaths=true" 
], 
"taskSelector": "/t:", 
"showOutput": "silent", 
"tasks": [ 
    { 
     "taskName": "build", 
     // Show the output window only if unrecognized errors occur. 
     "showOutput": "silent", 
     // Use the standard MS compiler pattern to detect errors, warnings 
     // and infos in the output. 
     "problemMatcher": "$msCompile" 
    } 
] 

Aber Kompilieren (ctrl-shift-b) schlägt mit der Fehlermeldung: " Fehler beim externen Programm msbuild starten Laich msbuild ENOENT. „

2) Lesen Sie diesen Artikel: http://michaelcrump.net/creating-and-debugging-console-apps-with-vscode/, aber ich habe keine project.json Datei, auch‚dnx . run‘schlägt mit dem Fehler“ System.InvalidOp erationException: Das Projekt konnte nicht aufgelöst werden "

Gibt es eine einfache Möglichkeit, eine einfache C# -App in VS Code auszuführen? Ich frage mich, warum es so kompliziert ist. Wahrscheinlich vermisse ich etwas, irgendwelche Ideen sind willkommen.

Update 1: msbuild Zum Verlauf hinzufügen hilft

+0

VS-Code hat immer noch begrenzte Funktionen. Es wird viel einfacher sein, Ihre einfache C# -App in Visual Studio 2015 zu betreiben. – natemcmaster

+0

Haben Sie damit weitergekommen? Ich habe auch VSC gefunden und es wäre eine großartige schnelle Alternative zu VS für kleine Änderungen, aber ich bekomme den gleichen Fehler. – svanelten

+0

@svanelten, leider nicht. Aber ich habe die alte Version von VS Code benutzt, welche Version hast du? – pfedotovsky

Antwort

7

The C# support in VS Code is optimized for cross platform .NET development (DNX) (see working with ASP.NET 5 and VS Code for another relevant article. Our focus with VS Code is to be a great editor for cross platfrom C# development - for instance many Unity developers have been enjoying using VS Code in place of Mono Develop.

We support debugging of C# apps cross platfrom via Mono (see Mono Debugging).

Due to this focus many standard C# project types are not recognised by VS Code. An example of a non-supported project type is an ASP .NET MVC Application. In these cases if you simply want to have a lightweight tool to edit a file - VS Code has you covered. If you want the best possible experience for those projects, and development on Windows in general we recomend you use Visual Studio Community.

aus: code.visualstudio.com/Docs/languages/csharp


Update Juni 2017:

C# in Visual Studio-Code mit Microsofts VS unterstützt Code C# -Erweiterung: https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

Dies kann installiert werden, indem in Erweiterungen: Installationserweiterung nach 'C#' gesucht wird. Alternativ sollte beim Öffnen einer .cs Datei die Installation der Erweiterung angefordert werden.

Diese Erweiterung unterstützt das Debuggen von C# Anwendungen auf .NET Core- oder Mono jedoch nicht Unterstützung Debuggen von Anwendungen auf die laufenden Desktop-.NET Framework-Visual Studio Community ist immer noch für volle empfohlen. NET-Projektunterstützung.

Für weitere Informationen in Bezug auf C# Unterstützung des VS-Code, siehe # Erweiterung https://code.visualstudio.com/docs/languages/csharp

Für die Marktplatz-Seite für die VS-Code C, siehe https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

4

Sie einrichten können msbuild für den Aufbau voll .NET Apps ganz gut, Note Sie müssen entweder msbuild auf Pfad haben oder den vollständigen Pfad dazu in command Eigenschaft angeben.Dies ist, was beispielsweise Build-Task (gebunden an ctrl + shift + b) wie folgt aussieht:

{ 
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format 
    "version": "0.1.0", 
    "command": "MSBuild.exe", 
    "args": [ 
     // $msCompile requires GenerateFullPaths=true, rest is optional. I set it to build Debug/Any CPU and use parallel project build 
     "${workspaceRoot}/src/ExampleSolution.sln", 
     "/p:Configuration=Debug;Platform=Any CPU;GenerateFullPaths=true", 
     "/m" 
    ], 
    "taskSelector": "/t:", 
    "showOutput": "silent", 
    "echoCommand": true, 
    "tasks": [ 
     { 
      "taskName": "Rebuild", 
      // Required if you want "Rebuild", not build as your target and still use ctrl + shift + b hotkey 
      "isBuildCommand": true, 
      // Show the output window only if unrecognized errors occur. 
      "showOutput": "silent", 
      // Use the standard MS compiler pattern to detect errors, warnings and infos 
      "problemMatcher": "$msCompile" 
     } 
    ] 
} 

UPD: Wenn Sie beide Gebäude und Unit-Test-Betrieb einrichten möchten, können Sie so etwas wie dieses (verwendet nunit Konsole Läufer verwenden können und cmd als Aufgabe nur einzelne Aufgabe unterstützen zu hacken um vscode Begrenzung):

{ 
    "version": "0.1.0", 
    "command": "cmd", 
    "args": [ 
     "/c" 
    ], 
    "showOutput": "always", 
    "echoCommand": true, 
    "tasks": [ 
     { 
      "isBuildCommand": true, 
      "taskName": "MSBuild.exe", 
      "args": [ 
       "${workspaceRoot}/src/Example.sln", 
       "/t:Rebuild", 
       "/p:Configuration=Debug;Platform=Any CPU;GenerateFullPaths=true", 
       "/m" 
      ], 
      "showOutput": "always", 
      "problemMatcher": "$msCompile" 
     }, 
     { 
      "taskName": "nunit3-console.exe", 
      "args": [ 
       "${workspaceRoot}/src/Example.sln" 
      ], 
      "showOutput": "always" 
     } 
    ] 
} 
1

Hatte das gleiche Problem. Geänderter direkter Pfad zu Msbuild behoben:

{ 
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format 
    "version": "0.1.0", 
    "windows": { 
     "command": "C:\\Program Files(x86)\\MSBuild\\14.0\\Bin\\MSBuild.exe" 
    }, 
    // "command": "msbuild", 
    "args": [ 
     // Ask msbuild to generate full paths for file names. 
     "/property:GenerateFullPaths=true" 
    ], 
    "taskSelector": "/t:", 
    "showOutput": "silent", 
    "tasks": [ 
     { 
      "taskName": "build", 
      // Show the output window only if unrecognized errors occur. 
      "showOutput": "silent", 
      // Use the standard MS compiler pattern to detect errors, warnings and infos 
      "problemMatcher": "$msCompile" 
     } 
    ] 
} 
Verwandte Themen