PrettyBin icon indicating copy to clipboard operation
PrettyBin copied to clipboard

Build error - cannot move file to \lib

Open EvAlex opened this issue 10 years ago • 4 comments

Unable to move file "bin\Debug\CalcBinding.dll" to "bin\Debug\lib\CalcBinding.dll". Cannot create a file when that file already exists.

Clean, rebuild have no effect as the \lib folder is not removed on clean.

CalcBinding is a nuget package BTW.

EvAlex avatar Feb 15 '15 10:02 EvAlex

Turned out that file was held by vshost. I've managed to delete it only after closing Visual Studio.

But still something can be done: don't move file to lib if it is already there?

EvAlex avatar Feb 15 '15 10:02 EvAlex

I ran into this problem to this problem too. The problem could be solved very easily manually but is very troublesome. Could make some effort to fix this

Yukinyaa avatar Dec 01 '16 06:12 Yukinyaa

Just encountered this problem as well. A quick method that I used was ending the Program.vshost.exe process.

trigger-segfault avatar Mar 27 '18 18:03 trigger-segfault

Apparently ending the process does not permanently fix the issue. My issue also won't go away. Every time I build after a successful build I get the issue with the same dll: System.IO.Compression.dll.

Reopening Visual Studio did not fix the issue.

Alright, final solution:

  • Open your .csproj file and goto the Move task in the build actions section.
  • Append ContinueOnError="WarnAndContinue" to the end of the tag.

Should now look like this:

  <Target Name="AfterBuild">
    <ItemGroup>
      <MoveToLibFolder Include="$(OutputPath)*.dll ; $(OutputPath)*.pdb ; $(OutputPath)*.xml" />
    </ItemGroup>
    <Move SourceFiles="@(MoveToLibFolder)" DestinationFolder="$(OutputPath)lib" OverwriteReadOnlyFiles="true" ContinueOnError="WarnAndContinue"/>
  </Target>

This of course, will only work if the dlls causing the problem are not being modified. And don't need to be recopied if they already exist.

trigger-segfault avatar Mar 27 '18 18:03 trigger-segfault