2015-06-09 9 views
20

Voglio provare un nuovo editor di Microsoft - Codice di Visual Studio. Voglio implementare una semplice app (come Hello, World) ed essere in grado di eseguirne il debug. Ma dopo un sacco di google e di tentativi, non sono riuscito a farlo. È possibile? Ho installato Windows 10 con Visual Studio 2015.Codice di Visual Studio, supporto C# su Windows

Quello che ho cercato di fare:

1) Rimuovere il commento il seguente nel file tasks.json:

{ 
"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" 
    } 
] 

Ma la compilazione (Ctrl-Shift-b) non riesce con l'errore: " Impossibile avviare msbuild programma esterno uova msbuild ENOENT. "

2) Leggere questo articolo: http://michaelcrump.net/creating-and-debugging-console-apps-with-vscode/, ma non ho un file project.json, anche 'dnx . run' fallisce con l'errore" System.InvalidOp erationException: Impossibile risolvere il progetto "

Esiste un modo semplice per eseguire l'app C# semplice in VS Code? Mi sto chiedendo perché è così complicato. Probabilmente, mi manca qualcosa, qualsiasi idea è ben accetta.

Update 1: Aggiunta di MSBuild al percorso aiuta

+0

Il codice VS ha ancora funzionalità limitate. Sarà molto più semplice eseguire la tua semplice app C# in Visual Studio 2015. – natemcmaster

+0

Hai ottenuto qualcosa di più con questo? Ho anche appena trovato VSC e sarebbe una grande alternativa veloce a VS per piccole modifiche, ma ottengo lo stesso errore. – svanelten

+0

@svanelten, sfortunatamente, no. Ma ho usato la vecchia versione di VS Code, quale versione hai? – pfedotovsky

risposta

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.

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


Update, giugno 2017:

C# è supportato in codice Visual Studio utilizzando VS Microsoft Estensione del codice C#: https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

Questo può essere installato cercando "C#" nelle estensioni: Installa estensione. In alternativa, l'apertura di un file .cs dovrebbe richiedere l'installazione dell'estensione.

Questa estensione supporta il debug di applicazioni C# in esecuzione su .NET Nucleo o Mono, tuttavia non applicazioni supporto di debug in esecuzione sul Desktop .NET Framework-Visual Studio Community è ancora raccomandato per la piena. Supporto al progetto NET.

Per ulteriori informazioni per quanto riguarda C# sostegno di VS Codice, vedere https://code.visualstudio.com/docs/languages/csharp

Per la pagina mercato per il # estensione VS Codice C, vedi https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

4

È possibile impostare msbuild per la costruzione di servizi igienici .NET applicazioni bene, nota devi avere msbuild sul percorso o fornire il percorso completo ad esso nella proprietà command.Questo è ciò che compito esempio build (legato a ctrl + shift + b) assomiglia:

{ 
    // 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: Se si desidera impostare sia costruzione e unità di prova in funzione, è possibile utilizzare qualcosa di simile (usa nunit console corridore e cmd come un compito da incidere intorno vscode limitazione di supportare solo un'unica operazione):

{ 
    "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

avuto lo stesso problema. Modificato il percorso diretto a msbuild risolto:

{ 
    // 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" 
     } 
    ] 
} 
Problemi correlati