复制visual studio项目的最快方法/脚本是什么?

时间:2010-11-20 13:30:00

标签: visual-studio-2008 duplicate-data

您好 我已经设置了visual studio express c ++项目,其中包含了包含头文件和库的路径 现在,我想将此项目复制为包含头文件和库的相同路径 但是使用不同的名称,我不会手动进入.vcproj文件并开始更改名称 还有更好的办法吗?

2 个答案:

答案 0 :(得分:10)

执行此操作的最简单,最快捷的方法可能是使用Windows资源管理器来制作整个项目的副本。您很可能需要为复制的.vcproj文件分配新的唯一GUID。为此,请在记事本中打开该文件,然后从ProjectGUID或类似的应用程序中粘贴一个新的guidgen.exe。完成后,您只需在Visual Studio中打开重复项目并重命名即可。

或者,您可以尝试类似CopyWiz的内容(虽然我从未使用它,但有免费试用版可以查看它是否适合您)。

除非您尝试为新项目创建模板,否则会有a better way

答案 1 :(得分: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
相关问题