Какой самый быстрый способ / скрипт для дублирования проекта Visual Studio? - PullRequest
5 голосов
/ 20 ноября 2010

Hello Я настроил Visual Studio Express C ++ проект, с путями к включенным заголовкам и библиотекам Теперь мне нравится дублировать этот проект, чтобы он был с теми же путями к включенным заголовкам и библиотекам Но с другим именем я не могу зайти в файл .vcproj вручную и начать менять имена. Есть ли лучший способ?

Ответы [ 2 ]

10 голосов
/ 20 ноября 2010

Вероятно, самый простой и быстрый способ сделать это - использовать Windows Explorer, чтобы просто сделать копию всего проекта.Скорее всего, вам потребуется назначить скопированному файлу .vcproj новый уникальный идентификатор GUID.Для этого откройте файл в блокноте и вставьте новое ProjectGUID из guidgen.exe или аналогичное приложение.Сделав это, вы можете просто открыть дубликат проекта в Visual Studio и переименовать его.

В качестве альтернативы вы можете попробовать что-то вроде CopyWiz (хотя я никогда не использовалэто, есть бесплатная пробная версия, чтобы увидеть, работает ли она для вас).

Если вы не пытаетесь создать шаблон для новых проектов, в этом случае лучший способ .

1 голос
/ 20 августа 2011

Написал это, что работает для меня, если запустить в 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
...