.Net Core dotnet运行未运行最后修改的源代码 [英] .Net Core dotnet run is not running the last modified source code

查看:170
本文介绍了.Net Core dotnet运行未运行最后修改的源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用.Net Core 2.2进行Asp.Net Mvc项目。我无法从命令行/ powershell运行最后修改的源代码。我尝试在 dotnet运行 dotnet clean dotnet构建 >但没有用。如果我以前在Visual Studio 2019中运行/调试项目,则只能使用cli运行最后修改的源代码。

I am working on Asp.Net Mvc project with .Net Core 2.2. I can not run the last modified source code from command line/powershell. I tried manually calling dotnet clean and dotnet build before dotnet run but did not work. I can only run the last modified source code with cli if I run/debug my project within Visual Studio 2019 before.

如何解决此问题?

我正在使用Windows10。我同时安装了SDK版本3.1和2.2,但我通过

I am using Windows 10. I have both SDK versions 3.1 and 2.2 installed but I declare the version by

<PropertyGroup>
  <TargetFramework>netcoreapp2.2</TargetFramework>
  ...
</PropertyGroup>

在我的.csproj文件和构建路径中,目标版本正确。

in my .csproj file and in the build path the target version is correct.

推荐答案

TL; DR 问题出在构建错误的项目。确定正确的项目或 整体解决方案 dotnet构建主项目/入口项目/单个项目不会触发其他依赖项项目的构建。

TL;DR The problem was building the wrong project. Build the correct project or entire solution for certainty. dotnet build the main/entrance/single project does not trigger build for other dependency projects.

我正在研究一个包含许多项目的解决方案,其中一个是应用程序入口,该应用程序入口将其他项目作为依赖项。要运行该应用程序,您应该 dotnet运行这个项目。

I am working on a solution which has many projects, and one of them is the application entrance which has the other projects as dependency. To run the application, you should dotnet run this project.

我认为构建此入口项目也会触发该解决方案的依赖项目的构建。事实证明事实并非如此。

I thought building this entrance project would trigger build for dependency projects of the solution too. Turns out it does not.

诀窍是,您只能 dotnet运行项目,但可以 dotnet构建也是解决方案。所以我的解决办法是构建解决方案。

The trick is, you can dotnet run only projects but you can dotnet build also solutions. So my fix was to build the solution.

这篇关于.Net Core dotnet运行未运行最后修改的源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆