在我的.NET Core项目上运行dotnet build
命令时出现以下错误。
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]
我的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>
答案 0 :(得分:3)
所以,我在这里提出了解决方案
有进程运行和锁定程序集,因为我通过dotnet cli运行项目dotnet run
,我做了Ctrl + c
来终止正在运行的进程。但Ctrl + c
没有杀死所有进程,Childs继续运行并锁定程序集,即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.
命令你需要运行
netstat -ano -p TCP | find /I "listening" | find /I "{your port number}"
taskkill /F /PID {your process ID}
How to manually stop kestrel server
此问题的一些参考资料是:
How to manually stop kestrel server. Question asked on SO
terminating dotnet run
doesn't terminate child. Issue on github
答案 1 :(得分:1)
您的ASP.Net应用程序是从同一目录运行的,这就是您无法构建代码的原因。您有以下选择:
我会选择第一个选项,但如果你很难找到如何做,最后一个选项是最简单的。在任何情况下,如果由于任何原因你无法重新启动计算机,第二个肯定会工作。
答案 2 :(得分:1)
如果您的Web服务器是IIS,则可以在项目根目录中放置一个名为app_offline.htm
的空文件,这将正常关闭该应用程序。
我的脚本如下:
dotnet build
答案 3 :(得分:0)
添加新的迁移类时遇到了同样的问题。我的Visual Studio(2017)实例一直在冻结,当我重新启动Visual Studio时,我开始收到类似的消息。帮助我的是通过Windows任务管理器杀死 dotnet.exe 进程。
答案 4 :(得分:0)
对我来说,解决方案是通过右键单击任务栏图标来停止IIS Express进程。
或者您可以在“预构建事件”中创建命令行:
$(Solution)taskkill / FI“ IMAGENAME eq iisexpress.exe” / F
我们没有时间在“构建”部分的“输出”视图中查看命令是否已正确执行。在“预构建事件”中添加此命令行以查看结果:
cmd / c暂停
您可以在选中后删除此行...
答案 5 :(得分:0)
VisualStudio Code中的一个简单解决方案就是杀死终端。
然后通过在“终端”选项卡(“终端-新终端”)中启动新终端或使用快捷方式Ctrl + Shift + `
答案 6 :(得分:0)
答案 7 :(得分:0)
对于像我这样在共享主机上有此问题且无法访问任何内容的人,请不要尝试直接通过面板或FTP复制dll,将其压缩然后上传,然后以这种方式将其解压缩以在Plesk中运行面板。