Heldenkrieger01
Heldenkrieger01

Reputation: 369

Build C# in VSCode not working

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?

Upvotes: 3

Views: 3385

Answers (2)

mm8
mm8

Reputation: 169220

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.

If you want the best possible experience when creating WPF applications, you should use Visual Studio.

Upvotes: 2

Marcel
Marcel

Reputation: 1463

I don't think that VSCode supports WPF since it focusses on projects built with .NET Core and Mono. WPF is not supported in .NET Core

Upvotes: 1

Related Questions