dotnet build在.NET Core项目上运行命令时出现以下错误。
C:\Program Files\dotnet\sdk\2.1.2\Microsoft.Common.CurrentVersion.targets(4106,5
): warning MSB3026: Could not copy "obj\Debug\netcoreapp2.0\Blog-Yantra.dll" to
"bin\Debug\netcoreapp2.0\Blog-Yantra.dll". Beginning retry 1 in 1000ms. The proc
ess cannot access the file 'E:\learn\blog\Blog-Yantra\bin\Debug\netcoreapp2.0\Bl
og-Yantra.dll' because it is being used by another process. [E:\learn\blog\Blog
-Yantra\Blog-Yantra.csproj]
Run Code Online (Sandbox Code Playgroud)
我的csproj文件如下所示:
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>
<TypeScriptToolsVersion>2.3</TypeScriptToolsVersion>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.0.1" />
<PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.0.1" />
</ItemGroup>
<ItemGroup>
<DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
所以,在这里我想出了解决方案。
有进程正在运行和锁定程序集,因为我确实dotnet run通过 dotnet cli 运行了项目,而我做了Ctrl+c来终止正在运行的进程。但是Ctrl+c并没有杀死所有进程,Childs 继续运行并锁定程序集,即 kestrel 服务器仍在同一端口上运行。
为了杀死正在运行的 kestrel 服务器,我运行了以下命令。
C:\Users\Kiran>netstat -ano -p TCP | find /I "listening" | find /I "2492"
TCP 127.0.0.1:2492 0.0.0.0:0 LISTENING 820
C:\Users\Kiran>taskkill /F /PID 820
SUCCESS: The process with PID 820 has been terminated.
Run Code Online (Sandbox Code Playgroud)
你需要运行的命令
netstat -ano -p TCP | find /I "listening" | find /I "{your port number}"
taskkill /F /PID {your process ID}
Run Code Online (Sandbox Code Playgroud)
这个问题的一些参考是:
| 归档时间: |
|
| 查看次数: |
6299 次 |
| 最近记录: |