.Net Core dotnet run is not running the last modified source code

别来无恙 提交于 2020-05-17 06:57:48

问题


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.

How can i solve this problem?

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>

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


回答1:


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.

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.

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



来源:https://stackoverflow.com/questions/61253916/net-core-dotnet-run-is-not-running-the-last-modified-source-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!