问题
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