dnu发布,该进程无法访问文件

时间:2015-08-06 00:39:02

标签: asp.net-core

当我通过dnu publish将我的dnx网络应用程序发布到IIS服务器时,它可以正常使用看起来像这样的脚本

dnu publish pathToLocalSource --out \\appserver\appuat --configuration DEBUG --no-source --runtime dnx-clr-win-x64.1.0.0-beta6

它工作得很好 - 直到有人点击网站,然后由于文件锁定而无法再发布

Microsoft .NET Development Utility CLR-x64-1.0.0-beta6-12256

Executing script 'prepare' in project.json
Copying to output path \\appserver\appuat
Using Package dependency Microsoft.AspNet.Mvc 6.0.0-beta6
Adding NuGet package C:\Users\[username]\.dnx\packages\Microsoft.AspNet.Mvc\6.0.0-
beta6\Microsoft.AspNet.Mvc.6.0.0-beta6.nupkg to \\appserver\appuat\approot\packages
Installing Microsoft.AspNet.Mvc.6.0.0-beta6
System.IO.IOException: The process cannot access the file '\\appserver\appuat\approot\packages\Microsoft.AspNet.Mvc\6.0.0-b
eta6\lib\dnx451\Microsoft.AspNet.Mvc.dll' because it is being used by another pr
ocess.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, I
nt32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions o
ptions, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolea
n useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access,
FileShare share)
   at Microsoft.Framework.PackageManager.Publish.PublishOperations.ExtractFiles(
ZipArchive archive, String targetPath, Func`2 shouldInclude)
   at Microsoft.Framework.PackageManager.NuGetPackageUtils.ExtractPackage(String
 targetPath, FileStream stream)
   at Microsoft.Framework.PackageManager.NuGetPackageUtils.<>c__DisplayClass0_0.
<<InstallFromStream>b__0>d.MoveNext()

我可以通过RDP解决这个问题,然后执行iisreset

推荐的解决方法是什么?首先发布app_offline.htm

1 个答案:

答案 0 :(得分:1)

因此,由于这是一个UAT盒子,我可以放松安全设置,我将其添加到我的部署脚本中:

iisreset $targetMachine /restart

脚本的执行者需要是$targetMachine的本地管理员。