I have a script to copy all artifact dotnet to remote server (from Jenkins server to IIS folder on remote server) for Deploy Stage like below:
#Parameters
param($userName, $passWord, $serverName, $deployFolder, $destinationFolder, $iisName)
$passwd = ConvertTo-SecureString $passWord -AsPlainText -Force
$creds = New-Object -typename System.Management.Automation.PSCredential -argumentlist $userName, $passwd
$session = New-PSSession -ComputerName $serverName -Credential $creds
#Stop IIS Application
Invoke-Command -Session $session -ScriptBlock { Import-Module IISAdministration; Stop-Website $args[0];} -ArgumentList $iisName
Start-Sleep -s 200
#Copy new build to deploy folder
Copy-Item -Recurse -Force -Path $deployFolder -Destination $destinationFolder -ToSession $session
#Start IIS Application
Invoke-Command -Session $session -ScriptBlock { Import-Module IISAdministration; Start-Website $args[0];} -ArgumentList $iisName
But sometimes I got issue Copy-Item : The process cannot access the file 'dll' because it is being used by another process.
Any ideas? Please let me know!
Thanks
question from:
https://stackoverflow.com/questions/65896101/copy-item-the-process-cannot-access-the-file-dll-because-it-is-being-used-by 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…