How to convert bdsproj to dproj?

We recently upgraded from Delphi 2006 to Delphi 2007, and the project files changed from .bdsproj to .dproj .

My research so far shows that an existing project must be open to create .dproj in the D2007 IDE. We have more than 400 .bdsproj files, so doing it manually is not very convenient.

The process I came across was to open all projects from the command line using:

 find . -name *.bdsproj -exec bds.exe -pDelphi -ns -m "{}" ";" 

This is not ideal, because it is rather slow (wait until BDS boots up, wait for compilation, wait until BDS closes, ...).

Is there an efficient way to convert multiple .bdsproj to .dproj ?

Note. β€œFound” on the command line above is a UNIX-like search (for example, MKS or GNU) that searches for files, not a Windows search that searches for text in files.

+6
delphi delphi-2007
source share
3 answers

Below is a more convenient version of find using PowerShell. It searches for bdsproj files in the specified directory and creates a bdsgroup containing all the projects.

After running the script, open bdsgroup with D2007 to convert projects to dproj . The D2007 also produces groupproj , which seems to be the equivalent of the D2007 bdsgroup .

Tips:

  • Run the script with -help to see the instructions.
  • Launch D2007 before opening bdsgroup , it seems that the process is faster.
  • You do not need to save projects; to open them, just create dproj .

Thanks to:

  • Ulrich Gerhardt , offering a bdsgroup approach.
  • dangph for help with PowerShell script.

Here is the script. This works for me: o)

 Param( $path = ".", $exclude = "", [switch]$help ) Set-PSDebug -Strict $ErrorActionPreference = 'Stop' # Ensure path is fully qualified and ends with a path delimiter $path = Join-Path (Resolve-Path $path) "" # Output file full name ($path\scriptname.bdsproj) $outfile = Join-Path $path ([IO.Path]::ChangeExtension($MyInvocation.MyCommand.Name, "bdsgroup")) # Bdsgroup template $groupXml = [xml]@" <?xml version="1.0" encoding="utf-8"?> <BorlandProject> <PersonalityInfo> <Option> <Option Name="Personality">Default.Personality</Option> <Option Name="ProjectType"></Option> <Option Name="Version">1.0</Option> <Option Name="GUID">{$([guid]::NewGuid().ToString())}</Option> </Option> </PersonalityInfo> <Default.Personality> <Projects> <Projects Name="Targets"></Projects> </Projects> <Dependencies/> </Default.Personality> </BorlandProject> "@ ### Functions ### function ShowUsage() { $myName = Split-Path -Leaf $MyInvocation.ScriptName Write-Host "Usage:" Write-Host "`t$myName [-path <Path>] [-exclude <Exclude>] [-help]" Write-Host Write-Host "`t-path <Path>" Write-Host "`t`tSpecifies the directory to begin searching for *.bdsproj." Write-Host "`t`tPath:" $path Write-Host Write-Host "`t-exclude <Exclude>" Write-Host "`t`tSpecifies a directory to exclude from the search." Write-Host "`t`tExclude:" $exclude Write-Host Write-Host "`t-help" Write-Host "`t`tDisplays this message." Write-Host Write-Host "Output will be written to:" Write-Host "`t" $outfile Write-Host Write-Host "Limitations:" Write-Host "`tDoes not support multiple directories for Path or Exclude." } # Get the target name. # eg "D:\dev\src\foo.bdsproj" returns "foo.exe" function GetTarget($bdsproj) { $mainSource = GetMainSource($bdsproj) $ext = GetTargetExt($mainSource) Split-Path -Leaf ([IO.Path]::ChangeExtension($mainSource, $ext)) } # Get the relative project path. # eg If path is "D:\dev" then "D:\dev\src\foo.bdsproj" returns "src\foo.bdsproj" function GetProject($bdsproj) { $prefixLen = $path.Length $suffixLen = $bdsproj.Length - $prefixLen $bdsproj.Substring($prefixLen, $suffixLen) } # Get the fully qualified MainSource (dpr/dpk) path. # eg "D:\dev\src\foo.bdsproj" returns "D:\dev\src\foo.dpr" function GetMainSource($bdsproj) { $projXml = [xml](Get-Content $bdsproj) $mainSource = $projXml.BorlandProject."Delphi.Personality".Source.Source | Where-Object { $_.Name -eq "MainSource" } $result = Join-Path (Split-Path -Path $bdsproj) $mainSource.InnerText if (-not (Test-Path $result)) { throw "No MainSource (dpr/dpk) found for $bdsproj" } $result } # Get the target extension depending on the source type. function GetTargetExt($mainSource) { $targets = @{"package"="pkg"; "library"="dll"; "program"="exe"} $targetType = GetTargetType($mainSource) $targets[$targetType] } # Read the target type out of the dpr. function GetTargetType($mainSource) { $name = [IO.Path]::GetFileNameWithoutExtension($mainSource) $pattern = "^\s*(package|library|program)\s+$name;$" $matches = (Select-String -Path $mainSource -Pattern $pattern) if ($matches -eq $null) { throw "Unknown target type (pkg/dll/exe) for $mainSource" } $matches.Matches[0].Groups[1].Value } # Add a project entry to groupXml. # eg <Projects Name="foo.exe">src\foo.bdsproj</Projects> function AddProject($target, $project) { $node = $groupXml.CreateElement("Projects") $node.SetAttribute("Name", $target) $node.InnerText = $project $groupXml.BorlandProject."Default.Personality".Projects.AppendChild($node) | Out-Null $targets = $groupXml.BorlandProject."Default.Personality".Projects.Projects | Where-Object { $_.Name -eq "Targets" } $targets.InnerText = $targets.InnerText + " " + $target } ### Main ### if ($help) { ShowUsage } else { Get-ChildItem -Path $path -Include "*.bdsproj" -Recurse | Where-Object { $exclude -eq "" -or $_.FullName -notmatch $exclude } | ForEach-Object { AddProject (GetTarget $_.FullName) (GetProject $_.FullName) } $groupXml.OuterXml | Out-File -Encoding "UTF8" $outfile } 
+3
source share

You can open several projects at once. Even using drag and drop.

  • Choose 40 projects
  • Drag them to the IDE
  • Click Yes 40 times
  • Save all
  • close all
  • Repeat to the end.
+3
source share

Perhaps you could use a command line similar to your find (and possibly a small Delphi program) to create a * .bdsgroup file with all projects and open it in D2007.

+2
source share

All Articles