通过一些需求改进,我最终得到了这个脚本:
$match = "MyAssembly" $replacement = Read-Host "Please enter a solution name" $files = Get-ChildItem $(get-location) -filter *MyAssembly* -Recurse $files | Sort-Object -Descending -Property { $_.FullName } | Rename-Item -newname { $_.name -replace $match,$replacement } -force $files = Get-ChildItem $(get-location) -include *.cs,*.csproj,*.sln -Recurse foreach($file in $files) { ((Get-Content $file.fullname) -creplace $match,$replacement) | set-content $file.fullname } read-host -prompt "Done! Press any key to close."