如何在 TeamCity 的 .NET 项目中包含解决方案目录之外的依赖项 [英] How to include dependencies outside solution directory in .NET project for TeamCity

查看:33
本文介绍了如何在 TeamCity 的 .NET 项目中包含解决方案目录之外的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的解决方案目录外有类库,所以我在 *.sln 文件../SomeDependency.csproj"中有这样的引用在 VS 中一切正常,但 TeamCity 在尝试构建我的解决方案时失败.我猜它复制了所有解决方案目录,因此关系不再存在.

I have class library outside my solution directory, so I have reference like this in *.sln file "../SomeDependency.csproj" In VS everything is ok, but TeamCity failed when try to build my solution. I guess it copy all solution directory so relation doesn't exists any more.

这是我的错误C:\TeamCity\buildAgent\work\799db5684a98650b\blablabla.sln.metaproj 错误 MSB3202:项目文件C:\TeamCity\buildAgent\work\799db5684a98650b....\Shared\Libraries\mysecretmyc‌r ret"未找到.

This is error I had C:\TeamCity\buildAgent\work\799db5684a98650b\blablabla.sln.metaproj error MSB3202: The project file "C:\TeamCity\buildAgent\work\799db5684a98650b....\Shared\Libraries\mysecretlib‌​rary\mysecretlibrary.csproj" was not found.

推荐答案

解决方案之外的类库生成可执行文件或 dll,很可能是 dll.使用 TeamCity 时,您应该在项目中引用此 dll,而不是外部项目本身.

The class library outside your solution produces either an executable or dll, most likely a dll. When working with TeamCity, this dll is what you should be referencing in your project, rather than the external project itself.

如果您对在 TeamCity 构建代理上构建外部库感到满意,请添加另一个构建配置来构建解决方案并将其作为工件发布,然后您可以添加对您的项目的引用以将此工件下载到已知的位置并直接引用它.(对于 TeamCity 构建,您可以在构建配置中将其设置为工件依赖项,对于本地构建,我建议您研究可以自动提供外部程序集的方法,我没有使用 Mercurial)

If you are happy for the external library to build on your TeamCity Build Agents, add another Build Configuration to build the solution and post it as an artifact, you can then add a reference to your project to download this artifact into a known location and reference it directly. (for TeamCity build you can set it as an artifact dependency in the build configuration, for local builds I suggest you look into ways you can provide the external assembly automatically, I have not used Mercurial)

如果这对您不起作用,您的另一个选择是将此库合并到解决方案中.仅当这是使用库的唯一地方时才这样做!我不提倡在您的解决方案周围复制项目,如果它在多个位置使用,那么您需要以兼容的方式提供它,作为TeamCity 中的工件参考,无论您发现如何最好地为您的本地构建提供程序集.

If this isn't going to work for you, your other option is to incorporate this library into the solution. Only do this if this is the only place the library is used! I am not advocating copying projects around your solutions, if its used in multiple locations then you need to provide it in a compatible way, as an artifact reference in TeamCity, and however best you find to provide the assembly for your local builds.

这篇关于如何在 TeamCity 的 .NET 项目中包含解决方案目录之外的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆