MiguelSlv
MiguelSlv

Reputation: 15103

Visual studio 2017 Publish web project to folder fails

The following errors pop in the log when publishing web project to folder.

....
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.

If i publish using web publish it works, but the real target doesn't support web publishing.

Note: VBCSCompiler is not running.

Upvotes: 1

Views: 1716

Answers (3)

Prabhat Maurya
Prabhat Maurya

Reputation: 1088

If you try to publish asp.net web app in Azure and getting above error then try to UPDATE the Microsoft.CodeDom.Providers.DotNetCompilerPlatform package to V1.0.7 or later. Initially, in your application, there will be Microsoft.CodeDom.Providers.DotNetCompilerPlatform version 1.0.5 then uninstall and then install the latest version V 1.0.7 or later of it. Clean your solution and build. Now you will be able to publish your web app in Azure using Visual Studio 2017.

Upvotes: 0

Julian Leite
Julian Leite

Reputation: 112

I had the same problem with my application with Visual Studio community 2017. In my case the solution was simple, I only deleted all the files inside the directory bin (C:\Projects\DotNet\ApplicationName\bin) and after I recompiled the application.

I hope it can help you.

Upvotes: 3

Joey Bob
Joey Bob

Reputation: 332

Had this same issue in Visual Studio 2017 Community Edition. As your question came up in Google but no answer, I thought I'd add to it.

I found Process Explorer from Sysinternals helped me a bunch.

Open sysinternals and go to Find -> Find Handle or DLL... or (Ctrl + F) and search the file that's being held open. In my case "System.IO.FileSystem.dll"

The search results showed two instances of MSBuild and one VBCSCompiler was hanging onto the files. Worst case, I just killed the process tree, built the project and all was well again.

Related answer: https://serverfault.com/questions/1966/how-do-you-find-what-process-is-holding-a-file-open-in-windows

Upvotes: 0

Related Questions