在 VisualStudio 2010 中,我们有一个场景,其中一个 dbproj (B) 引用另一个 dbproj (A)。
在 dbproj (A) 中,如果我将 Scripts 文件夹中的自定义 sql 脚本之一的构建操作设置为 «Copy always» 或 «Copy if newer» 构建 dbproj (B) 时构建失败(仅在构建服务器上)。它试图复制 (A) 中的文件,就像它在 (B) 中一样。
构建dbproj(A)时,输出如下,没问题:
_CopyOutOfDateSourceItemsToOutputDirectory:
Creating directory "D:\Builds\5\17\Binaries\Scripts".
Copying file from "Scripts\FortressMainUpdate.sql" to "D:\Builds\5\17\Binaries\Scripts\FortressMainUpdate.sql".
Copying file from "D:\Builds\5\17\Sources\Src\DataBase\MainDatabase\Scripts\FortressMainUpdate.sql" to "D:\Builds\5\17\Binaries\Scripts\FortressMainUpdate.sql".
然后在构建 dbproj (B) 时,服务器输出以下错误:
_CopyOutOfDateSourceItemsToOutputDirectory:
Building target "_CopyOutOfDateSourceItemsToOutputDirectory" partially, because some output files are out of date with respect to their input files.
Copying file from "Scripts\FortressOqtUpdate.sql" to "D:\Builds\5\17\Binaries\Scripts\FortressOqtUpdate.sql".
Copying file from "D:\Builds\5\17\Sources\Src\DataBase\OpenQueryTool\Scripts\FortressMainUpdate.sql" to "D:\Builds\5\17\Binaries\Scripts\FortressMainUpdate.sql".
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Microsoft.Common.targets(3129,9): error MSB3021: Unable to copy file "D:\Builds\5\17\Sources\Src\DataBase\OpenQueryTool\Scripts\FortressMainUpdate.sql" to "D:\Builds\5\17\Binaries\Scripts\FortressMainUpdate.sql". Could not find file **'D:\Builds\5\17\Sources\Src\DataBase\OpenQueryTool\Scripts\FortressMainUpdate.sql'**. [D:\Builds\5\17\Sources\Src\DataBase\OpenQueryTool\CCO.Fortress.Database.OpenQueryTool.dbproj]
Copying file from "D:\Builds\5\17\Sources\Src\DataBase\OpenQueryTool\Scripts\FortressOqtUpdate.sql" to "D:\Builds\5\17\Binaries\Scripts\FortressOqtUpdate.sql".
文件
D:\Builds\5\17\Sources\Src\DataBase\OpenQueryTool\Scripts\FortressMainUpdate.sql
是 dbproj (A) 中的那个,并且在 \DataBase\OpenQueryTool\Scripts\
中从未存在过.这仅发生在构建服务器上。在本地构建时,一切都很好。
我们的目标是将这些文件放在 tfs 放置位置,以及 dbproj 生成的 sql 文件,一旦构建了整个解决方案。
最佳答案
当前的解决方案是将文件复制到依赖项目文件夹中。
就我而言,我在主项目的 PreBuild 事件中执行此操作 - 了解两个项目之间的文件夹层次结构依赖关系。
关于tfs - 在我的 dbproj 中,在文件上设置 «Copy always» 或 «Copy if newer» 会使构建服务器上的构建失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8405305/