.NET Core锁定文件 [英] .NET Core locking files
问题描述
我有一个ASP.NET Core应用程序.我通过运行命令
I have a ASP.NET Core app. I run the application by running the command
dotnet run
在构建此ASP.NET Core应用时,在五分之一的情况下,我看到以下错误.
I'm seeing the following error in one out of five situations when I build this ASP.NET Core app.
C:... \错误CS2012:无法打开'C:... \ bin \ Debug \ netcoreapp1.0 \ AAA.Web.dll'进行写入-'该进程无法访问文件'C :. .. \ bin \ Debug \ netcoreapp1.0 \ AAA.Web.dll',因为它正在被另一个进程使用.'
C:...\error CS2012: Cannot open 'C:...\bin\Debug\netcoreapp1.0\AAA.Web.dll' for writing -- 'The process cannot access the file 'C:...\bin\Debug\netcoreapp1.0\AAA.Web.dll' because it is being used by another process.'
除了上述问题外,我还没有在CSHTML文件中进行任何更新.我必须停止dotnet run
命令,再次构建应用程序,然后运行dotnet run
命令.
In addition to the above issue, I also see no updates that I make in the CSHTML file. I have to stop the dotnet run
command, build the app again and then run the dotnet run
command.
如何解决这些问题?
推荐答案
在IIS中运行aspnetcore应用时,这可能也有帮助.
This may also help when running your aspnetcore app in IIS.
将以下内容添加到您的csproj:
Add the following to your csproj:
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="echo "App Offline" /a > "$(ProjectDir)app_offline.htm"" />
</Target>
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="del "$(ProjectDir)app_offline.htm"" />
</Target>
这篇关于.NET Core锁定文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!