简体   繁体   English

在 Visual Studio 中编写的 C# 代码不会在 Visual Studio Code 中运行

[英]C# code written in Visual Studio won't run in Visual Studio Code

I am trying to run a .NET Core Application in Visual Studio Code that was created in Visual Studio 2019. I'm having trouble with the dotnet run part, though.我正在尝试在 Visual Studio 2019 中创建的 Visual Studio Code 中运行 .NET Core 应用程序。不过,我在使用 dotnet 运行部分时遇到了问题。 It keeps giving me this error:它不断给我这个错误:

Unable to run your project.无法运行您的项目。
Ensure you have a runnable project type and ensure 'dotnet run' supports this project.确保您有一个可运行的项目类型,并确保“dotnet run”支持该项目。
A runnable project should target a runnable TFM (for instance, netcoreapp2.0) and have OutputType 'Exe'.一个可运行的项目应该针对一个可运行的 TFM(例如,netcoreapp2.0)并具有 OutputType 'Exe'。
The current OutputType is 'Exe'.当前的输出类型是“Exe”。

I have tried dotnet restore, dotnet build, dotnet clean, etc. Any suggestions on how to get this to run?我已经尝试过 dotnet restore、dotnet build、dotnet clean 等。关于如何让它运行有什么建议吗?

Terminal Output终端输出

I am not sure if this is your problem, but I experienced something similar recently.我不确定这是否是您的问题,但我最近经历了类似的事情。 Some applications coded in VS will not run in VS Code.一些在 VS 中编码的应用程序不会在 VS Code 中运行。 VS 2019 utilizes IIS Express to run applcations on localhost. VS 2019 利用 IIS Express 在本地主机上运行应用程序。 I do not believe VS Code has this ability as a text editor, compared to the power of VS 2019 as a IDE.与 VS 2019 作为 IDE 的强大功能相比,我不相信 VS Code 作为文本编辑器具有这种能力。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM