在另一个项目中引用一个项目的二进制文件

发布于 2024-09-04 04:45:17 字数 164 浏览 1 评论 0原文

新手问题:我在 TeamCity 中有 2 个 C# 项目,称它们为 A 和 B。A 包含对 B.dll 的引用。 B 构建得很好。但是,A 无法构建,因为它找不到 B:无法找到程序集“B”

这似乎很简单:如何告诉构建服务器上的项目 A 在哪里可以从 B\bin\Release 中找到二进制文件?

Newbie question : I have 2 C# projects in TeamCity, call them A and B. A contains a reference to B.dll. B builds fine. However, A fails to build because it cannot find B : Could not locate the assembly "B"

It seems really simple : how do I tell my project A on the buildserver where to find the binaries from B\bin\Release?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

何其悲哀 2024-09-11 04:45:17

您可以通过创建“工件”和工件依赖项来实现此目的。

如果项目 A 依赖于项目 B,那么您可以使用如下所示的工件路径在项目 B 上创建一个工件:

bin/Release/B.dll

然后在项目 A 上,您可以使用如下路径设置对 B 的工件依赖项:

B.dll

并将目标路径设置为项目 A 所在的位置期望找到 B.dll 例如,

./Libs

您可以做其他很酷的事情,例如使用以下语法自动将所有工件归档到 zip 中:

bin/Release/*.dll => B.zip

并通过以下方式访问它们:

B.zip!B.dll

所有这些路径都相对于构建目录,因此很容易,您不需要担心 TeamCity guid 文件夹或使用绝对路径。

You do this by creating 'Artifacts' and artifact dependencies.

If project A is dependent on project B, then you create an Artifact on project B using an artifact path like so:

bin/Release/B.dll

Then on project A you setup a artifact dependency on B with path like:

B.dll

And set the destination path to be where ever project A is expecting to find B.dll e.g.

./Libs

You can do other cool stuff like automatically archiving all your artifacts into a zip by using the syntax:

bin/Release/*.dll => B.zip

and access them via:

B.zip!B.dll

All these paths are relative to build directories so makes it easy and you dont need to worry about the TeamCity guid folders or use absolute paths.

满身野味 2024-09-11 04:45:17

您遇到的问题是,Teamcity 在其自己的临时目录中运行每个构建,并且由于这是随机生成的名称,因此您无法直接设置从一个到另一个的引用。

通常,您会编写一个构建脚本,以正确的顺序构建 A 和 B,然后让 Teamcity 运行该构建脚本。 (由于您使用的是 C#,因此 MSBuild 非常适合此操作)。

另一种方法是在构建结束时将 B.dll 复制到已知位置(例如 c:\currentbuild),并让 A 始终从此处引用它。您可以在 Teamcity 中设置构建依赖关系,以便在重建 B 时,也会重建 A。

The problem you're encountering is that Teamcity runs each build in it's own temporary directory and since this is a randomly generated name you can't set a reference directly from one to the other.

Typically you would write a build script that builds both A and B in the right order and just have Teamcity run that build script. (Since you're using C#, MSBuild is ideal for this).

The alternative would be to have B.dll copied to a known location (e.g. c:\currentbuild) at the end of its build and have A always reference it from here. You can set up build dependencies in Teamcity so that if B is rebuilt, A is also rebuilt.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文