2015-06-09 13 views
20

पर विजुअल स्टूडियो कोड, सी # समर्थन मैं माइक्रोसॉफ्ट - विजुअल स्टूडियो कोड से एक नया संपादक आज़माकर देखना चाहता हूं। मैं एक साधारण ऐप (जैसे हैलो, वर्ल्ड) को कार्यान्वित करना चाहता हूं और इसे डीबग करने में सक्षम हूं। लेकिन बहुत सारे गुस्सा और कोशिश करने के बाद, मैंने ऐसा करने का प्रबंधन नहीं किया। क्या यह संभव है? मेरे पास विजुअल स्टूडियो 2015 स्थापित विंडोज 10 है।विंडोज़

मुझे क्या करना की कोशिश की है:

1) टिप्पणी हटाएं 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" 
    } 
] 

लेकिन (संकलन Ctrl-Shift-ख) त्रुटि के साथ विफल: " । अंडे MSBuild ENOENT बाहरी कार्यक्रम MSBuild लॉन्च करने में विफल "

2) यह लेख पढ़ें: http://michaelcrump.net/creating-and-debugging-console-apps-with-vscode/, लेकिन मैं किसी भी project.json फ़ाइल नहीं है, यह भी" dnx . runSystem.InvalidOp "त्रुटि के साथ विफल" erationException: प्रोजेक्ट "

को हल करने में असमर्थ क्या वीएस कोड में सरल सी # ऐप चलाने का कोई आसान तरीका है? मैं सोच रहा हूं कि यह इतना जटिल क्यों है। शायद, मुझे कुछ याद आ रहा है, किसी भी विचार का स्वागत है।

अद्यतन 1: code.visualstudio.com/Docs/languages/csharp


अद्यतन जून 2017:

सी # माइक्रोसॉफ्ट के वी.एस. का उपयोग कर दृश्य स्टूडियो कोड में समर्थित है पथ के लिए MSBuild जोड़ना

+0

वीएस कोड में अभी भी सीमित सुविधाएं हैं। विजुअल स्टूडियो 2015 में अपना सरल सी # ऐप चलाने में बहुत आसान होगा। – natemcmaster

+0

क्या आपको इसके साथ और आगे मिला? मैंने अभी भी वीएससी पाया है और यह छोटे बदलावों के लिए वीएस के लिए एक शानदार त्वरित विकल्प होगा, लेकिन मुझे एक ही त्रुटि मिलती है। – svanelten

+0

@ svanelten, दुर्भाग्य से, नहीं। लेकिन मैंने वीएस कोड का पुराना संस्करण इस्तेमाल किया, आपके पास कौन सा संस्करण है? – pfedotovsky

उत्तर

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.

से मदद करता है कोड सी # एक्सटेंशन: https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

यह एक्सटेंशन में 'सी #' की खोज करके स्थापित किया जा सकता है: एक्सटेंशन इंस्टॉल करें। वैकल्पिक रूप से, .cs फ़ाइल खोलने से एक्सटेंशन इंस्टॉल करने के लिए संकेत देना चाहिए।

इस विस्तार के कोर या मोनो पर नेट चल सी # आवेदनों की डीबगिंग का समर्थन करता है, फिर भी नहीं समर्थन डिबगिंग आवेदनों पर डेस्कटॉप .नेट फ्रेमवर्क चल रहा है - Visual Studio Community अभी भी पूर्ण के लिए सिफारिश की है। नेट परियोजना समर्थन।

वी.एस. कोड के सी # समर्थन के बारे में अधिक जानकारी के लिए, वी.एस. कोड सी # विस्तार के लिए बाजार पृष्ठ के लिए https://code.visualstudio.com/docs/languages/csharp

देखते हैं, देखते हैं https://marketplace.visualstudio.com/items?itemName=ms-vscode.csharp

4

पूर्ण .NET क्षुधा ठीक, टिप्पणी के निर्माण के लिए msbuild सेट कर सकते हैं आपको या तो msbuild पथ पर होना चाहिए या command संपत्ति में इसके लिए पूर्ण पथ प्रदान करना होगा।

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

युपीडी: यह वही है उदाहरण के निर्माण कार्य (ctrl + shift + b करने के लिए बाध्य) की तरह लग रहा है कि आप दोनों के निर्माण और इकाई परीक्षण चल रहा है स्थापित करना चाहते हैं, तो आप कुछ इस तरह उपयोग कर सकते हैं (nunit सांत्वना धावक का उपयोग करता है और cmd एक कार्य के रूप में केवल एक कार्य का समर्थन करने का चारों ओर vscode सीमा हैक करने):

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

एक ही समस्या थी। Msbuild के लिए सीधा पथ बदल गया:

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