目在開發階段,不同網站的樣式 ( Theme )資料夾,經常需要手動覆蓋,用Powershell 將其自動化。
Function Get-Folder($initialDirectory) { [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms")|Out-Null $foldername = New-Object System.Windows.Forms.FolderBrowserDialog $foldername.Description = "Select a folder" $foldername.rootfolder = "MyComputer" $foldername.SelectedPath = $initialDirectory $foldername.ShowNewFolderButton = $false if($foldername.ShowDialog() -eq "OK") { $folder += $foldername.SelectedPath }else{ exit } return $folder } $defaultFolderName="Theme1" $currentPath = (Get-Item .).FullName + '\Src\Web.Portal\' + $defaultFolderName ; $desktopThemePath = Get-Folder($currentPath) $pathArray = $desktopThemePath.Split("\") $targetFolderName =$pathArray[$pathArray.length-1] $desktopProjectSource="..\Portal\Portal\Portal.Web\Web" robocopy $desktopThemePath $desktopProjectSource /E pause