functions/Copy-FromStaging.ps1
function Copy-FromStaging { [cmdletbinding()] param ( [string] $Path = ".", $stagingdir = $null, [Alias("NoConfig", "IgnoreConfig")][switch][bool] $ExcludeConfig = $false, $Exclude = @("log/", "App_Data/") ) $verbose = ($PSCmdlet.MyInvocation.BoundParameters["Verbose"].IsPresent -eq $true) if ([string]::IsNullOrEmpty($Path)) { } $projectName = split-path -leaf $Path if ($stagingDir -eq $null) { $stagingDir = "$Path\..\$projectName-staging" } if ($ExcludeConfig) { $f = Get-ConfigFile $stagingDir if ($f -ne $null) { $exclude += $f.Name } } Write-Host "Copy-FromStaging: exclude list=($Exclude). copying $stagingDir -> $path" if (test-path "$stagingDir\web.config") { write-host "copying web.config from '$stagingDir\web.config'" # start with web.config to force iis app pool recycle copy-item "$stagingDir\web.config" $path -Exclude $exclude -Verbose:$verbose # give IIS some time start-sleep -Seconds 1 } else { write-host "web.config at '$stagingDir\web.config' not found" } Copy-ItemFiltered -SourceDir $stagingDir -TargetDir $path -Excludes $exclude -Force -Verbose:$verbose #copy-item $stagingDir\* $path -Force -Recurse -Exclude $exclude -Verbose:$verbose -ErrorAction:Continue } |