Copy-Item : 该进程无法访问文件 'dll',因为它正被另一个进程使用
Copy-Item : The process cannot access the file 'dll' because it is being used by another process
我有一个脚本可以将所有工件 dotnet 复制到远程服务器(从 Jenkins 服务器到远程服务器上的 IIS 文件夹)以用于部署阶段,如下所示:
#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
但有时我会遇到问题 Copy-Item : The process cannot access the file 'dll' because it is being used by another process.
有什么想法吗?请告诉我!
谢谢
作为Bruce Zhang 的评论,我将stop app pool 添加到我的脚本中。有用。
Stop-WebAppPool -Name $args[0];
我有一个脚本可以将所有工件 dotnet 复制到远程服务器(从 Jenkins 服务器到远程服务器上的 IIS 文件夹)以用于部署阶段,如下所示:
#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
但有时我会遇到问题 Copy-Item : The process cannot access the file 'dll' because it is being used by another process.
有什么想法吗?请告诉我!
谢谢
作为Bruce Zhang 的评论,我将stop app pool 添加到我的脚本中。有用。
Stop-WebAppPool -Name $args[0];