Home:ALL Converter>Build C# in VSCode not working

Build C# in VSCode not working

Ask Time:2017-11-02T17:36:45         Author:Heldenkrieger01

Json Formatter

I'm trying to build my C# (WPF) project, which I originally generated in Visual Studio 2017 in VSCode. If I open a command prompt and build the project with C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe .\[Name]\[Name].csproj /t:Rebuild /p:Configuration=Debug

the build succeeds and the program runs as expected, but with the following message (not a warning nor an error):

Project file contains ToolsVersion="15.0". This toolset may be unknown or missing, in which case you may be able to resolve this by installing the appropriate version of MSBuild, or the build may have been forced to a particular ToolsVersion for policy reasons. Treating the project as if it had ToolsVersion="4.0".

But when I try to run and build in VSCode (Start with Debugging (F5)), the build fails. Also, VSCode shows every XAML-Element I referenced in code as undefined:

(The name '[Button/Label/TextBox/etc.]' does not exist in the current context [Name]

What do I need to define in the tasks.json and launch.json to make VSCode build my project?

Author:Heldenkrieger01,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/47071911/build-c-sharp-in-vscode-not-working
mm8 :

The C# support in VS Code is optimized for cross-platform .NET Core development. WPF is neither cross-platform nor .NET Core and VS Code does not support debugging WPF applications. Due to this focus, many of the standard C# project types are not recognized by VS Code: https://code.visualstudio.com/docs/languages/csharp.\n\nIf you want the best possible experience when creating WPF applications, you should use Visual Studio.",
2017-11-02T16:40:41
yy