Our Developers work with VisualStudio 2017
They use a Post-Build PowerShell function that I wrote, to publish the application to the correct destination.
Sometimes (1 out of 100 times) they get the following error:
Copy-Item : The process cannot access the file 'X:\xy\application.exe' because it is
9> being used by another process.
The thing is - it is not used by another process. Any other user (e.g me) can rename the file in the destination, delete it or whatever.
When the developer restarts his computer, he can publish the application without a problem.
So it looks like to me that his filesystem messes up something. we tried
taskkill /im explorer.exe /f && start "" explorer.exe
but that didn't help.
If the developer looks into the destination with his explorer, the destination file is present for the developer, even after i deleted it.
How can this be? And how can we fix this?
The PowerShell function itself is very lightweight. It basically does this for deploying:
Write-Host "Starting Copying files to $d"
$Copy = Copy-Item $FilesToPublish $d -Force -Recurse
Write-Host "Finished Copying files to $d"
if specified (and it was specified), the function will also delete all locks for the destination
Get-SmbOpenFile -CimSession $Session | ? { $_.Path -like "$EndPath*" } | Close-SmbOpenFile -Force -PassThru
but the error also occurs, if we don't specify unlocking.