Visual Studio 2017将Web项目发布到文件夹失败

时间:2017-08-16 14:09:36

标签: visual-studio-2017 roslyn

将Web项目发布到文件夹时,日志中会弹出以下错误。

....
Publishing folder /...
Publishing folder bin...
Publishing folder bin/es...
Publishing folder bin/roslyn...
Unable to add 'bin/roslyn/System.IO.FileSystem.dll' to the Web site.  Unable to add file 'bin\roslyn\System.IO.FileSystem.dll'.  The process cannot access the file because it is being used by another process.
Unable to add 'bin/roslyn/System.IO.FileSystem.Primitives.dll' to the Web site.  Unable to add file 'bin\roslyn\System.IO.FileSystem.Primitives.dll'.  The process cannot access the file because it is being used by another process.
Unable to add 'bin/roslyn/System.Reflection.Metadata.dll' to the Web site.  Unable to add file 'bin\roslyn\System.Reflection.Metadata.dll'.  The process cannot access the file because it is being used by another process.
Unable to add 'bin/roslyn/System.Security.Cryptography.Algorithms.dll' to the Web site.  Unable to add file 'bin\roslyn\System.Security.Cryptography.Algorithms.dll'.  The process cannot access the file because it is being used by another process.
Unable to add 'bin/roslyn/System.Security.Cryptography.Primitives.dll' to the Web site.  Unable to add file 'bin\roslyn\System.Security.Cryptography.Primitives.dll'.  The process cannot access the file because it is being used by another process.
Unable to add 'bin/roslyn/System.ValueTuple.dll' to the Web site.  Unable to add file 'bin\roslyn\System.ValueTuple.dll'.  The process cannot access the file because it is being used by another process.
Unable to add 'bin/roslyn/VBCSCompiler.exe' to the Web site.  Unable to add file 'bin\roslyn\VBCSCompiler.exe'.  The process cannot access the file because it is being used by another process.
Publishing folder bin/zh...
...
Publishing folder Views/WFDefs...
Publish failed. Target file://machine/d$/PATH.

如果我使用网络发布发布它是有效的,但真正的目标不支持网络发布。

注意:VBCSCompiler没有运行。

2 个答案:

答案 0 :(得分:2)

我的Visual Studio社区2017应用程序遇到了同样的问题。在我的情况下,解决方案很简单,我只删除了目录bin中的所有文件(C:\ Projects \ DotNet \ ApplicationName \ bin),之后我重新编译了应用程序。

我希望它可以帮到你。

答案 1 :(得分:0)

在Visual Studio 2017社区版中遇到同样的问题。当你的问题出现在谷歌但没有回答时,我想我会加入它。

我发现Process Explorer Sysinternals给了我很多帮助。

打开sysinternals并转到查找 - >查找句柄或DLL ...或(Ctrl + F)并搜索保持打开的文件。在我的情况下" System.IO.FileSystem.dll"

搜索结果显示两个MSBuild实例和一个VBCSCompiler挂在文件上。最糟糕的情况是,我刚刚杀了进程树,构建了项目,一切都很好。

相关答案:https://serverfault.com/questions/1966/how-do-you-find-what-process-is-holding-a-file-open-in-windows