PrettyBin
PrettyBin copied to clipboard
Build error - cannot move file to \lib
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.
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?
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
Just encountered this problem as well. A quick method that I used was ending the Program.vshost.exe
process.
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.