现在我有2个平台(Mac和Win32)和2个配置(Debug ans Release)。整件事都在SVN下。
以下是构建输出的布局:
.\App\$(Platform)\$(Config)
代码分为几个文件夹,位于此处:
.\Code\MyProject.dpr
.\Code\Common\
.\Code\Forms\
.\Code\Source\
公共数据文件在这里:
.\Data\ custom data files (dlls, textures, models, etc.)
这个方案有一定的缺陷,我需要解决,但我不知道如何让它变得更好。我想在数据文件夹下的SVN中只有一组数据文件,但我需要在构建时自动将其复制到.\App\$(Platform)\$(Config)
路径(注意,某些数据文件对于两个平台都是通用的,但有些不是) 。有没有办法设置构建过程来复制文件,就像部署和PAServer一样?或者,我可以将数据文件的路径设置为..\..\Data
,但这看起来很奇怪。
也许还有其他一些我不知道的选项,或者项目布局可以完全改变?您将如何设置项目结构并构建跨平台编译?
答案 0 :(得分:7)
使用Post Build操作。
来自项目选项|构建事件|发布活动|命令
进一步阅读
答案 1 :(得分:0)
好的,这是一篇旧文章,但这是我在Delphi中做的(同样在Visual Studio中),以解决在不同文件夹中具有不同平台/配置输出可执行文件的问题,但这是一组通用数据。我有一个功能来剥离" sub"文件夹部分,然后我的应用程序可以随时访问这些文件夹的根目录中的公共数据(在您的情况下。\ App)。当然,您可以根据需要为ProjectPath添加更多平台和配置:
uses System.StrUtils;
...
function ProjectPath : string;
// Removes sub-folders created by the Delphi IDE, so the executable can refer to the source folder,
// rather than to where the executable is.
// Excludes trailiong path delimiter
begin
Result := ExtractFilePath (Application.ExeName);
Result := System.StrUtils.ReplaceText (Result, '\Win32' , ''); // ReplaceText is case insensitive
Result := System.StrUtils.ReplaceText (Result, '\Win64' , '');
Result := System.StrUtils.ReplaceText (Result, '\Debug' , '');
Result := System.StrUtils.ReplaceText (Result, '\Release', '');
Result := ExcludeTrailingPathDelimiter (Result);
end;
...
ConnectionString := 'Database=' + ProjectPath +'\DATAFILE.DAT;etc.';