5

您好,我已经设置了 Visual Studio Express C++ 项目,其中包含包含头文件和库的路径现在我想复制这个项目以使用相同的路径包含头文件和库但是名称不同,我不知道手动进入。 vcproj 文件并开始更改名称有更好的方法吗?

4

2 回答 2

10

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

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

除非您尝试为新项目创建模板,否则有更好的方法

于 2010-11-20T13:40:23.510 回答
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
于 2011-08-19T20:19:48.987 回答