2010-11-20 70 views

回答

9

也許最簡單快速的方法是使用Windows資源管理器來製作整個項目的副本。您很可能需要爲複製的.vcproj文件分配一個新的唯一GUID。爲此,請在記事本中打開文件,並從guidgen.exe或類似應用程序中粘貼新的ProjectGUID。完成之後,只需在Visual Studio中打開重複的項目並重新命名即可。

另外,你可以嘗試像CopyWiz(雖然我從來沒有使用它,有一個免費的試用版可用來查看它是否適用於你)。

除非您正在嘗試爲新項目創建模板,在這種情況下有a better way

+0

對於那些誰不知道GUIDGEN.EXE的位置: 「C:\ Program Files文件\微軟的SDK \的Windows \ v6.0A \ BIN」(我的系統是Windows 7專業版64位,VS 2005,2008年&2010安裝) – kubilay 2012-09-27 14:51:42

1

如果在PowerShell中運行(在Win 7和其他版本中提供),請編寫這個適用於我的程序 即使它不能正確工作,它也可能是一個很好的起點。

# set the initial values. 
[System.Reflection.Assembly]::LoadWithPartialName(「System.Windows.Forms」) 
[Windows.Forms.MessageBox]::Show(「This script assumes that each project lives in a directory with the same name as the project, as VC defaults to. Input a) the directory holding both the existing project and the new project. This is the directory CONTAINING the directory with the name of the existing project. It must include the final backslash. b) the name of the existing project. c) the name of the new project」, 「」, [Windows.Forms.MessageBoxButtons]::OK,  [Windows.Forms.MessageBoxIcon]::Information) 
($myroot=(Read-Host "Enter path of directory holding new and existing projects.")) 
($projectname=(Read-Host "Enter the name of the project to copy. Must be a single word")) 
($newname=(Read-Host "Enter the name of the new project. Must be a single word")) 

# make a copy of the original 
Set-Location $myroot 
Copy-Item "$myroot$projectname" "$myroot$newname" -recurse 


# find and rename all files containing the original project name 
# run without recurse first or an error occurs 
Get-ChildItem $myroot$newname\ -force| Where-Object {$_.name -like "*$projectname*"}| rename-item -newname { $_.name -replace "$projectname","$newname" } 
Get-ChildItem $myroot$newname\ -force -recurse| Where-Object {$_.name -like "*$projectname*"}| rename-item -newname { $_.name -replace "$projectname","$newname" } 

# find all references within the code to the projectname and change those 
Set-Location $myroot$newname 
Get-ChildItem -recurse | where {$_.extension -eq ".cpp"-or $_.extension -eq ".h" -or $_.extension -eq ".sln" -or $_.extension -eq ".vcxproj" -or $_.extension -eq ".rc"} ` 
|foreach-object {(get-content $_.fullname) | foreach-object {$_ -replace "$projectname", "$newname"} | set-content $_.fullname} 

# delete sdf and suo files 
remove-item $myroot$newname\$newname.suo -force 
remove-item $myroot$newname\$newname.sdf -force 


#done 
相關問題