TeamCity 在构建项目时包含 dll 作为参考

TeamCity includes dll as reference when building project

我们有一个包含 win32 dll 作为 content 文件的项目。此文件 (native32.dll) 被复制到输出目录并在运行时导入。 Visual studio 编译项目没有任何问题,但是 TeamCity 获取此 .dll 文件(或项目结构中包含的任何 .dll 文件)并将其视为参考:

  csc.exe <..> /reference:native32.dll <..>

构建失败并出现错误:

CSC error CS0009: Metadata file 'native32.dll' could not be opened -- PE image doesn't contain managed metadata

如何排除这个native32.dll被引用?

您需要创建一个 Class Library 并将 DLL 与 wrapper/interop class 一起包含在该库中。然后只需从您之前无法编译的其他项目中引用 class 库。