使用 NuGet 包构建团队城市

发布于 2024-12-21 05:59:47 字数 1395 浏览 1 评论 0原文

我已经在 team city 中建立了一个构建,并在测试项目中提供了 NuGet 包引用。

我使用的文件夹结构是

\
|- Project1
  \- Project1.csproj
|-  Project1.Test
 \- Project1.Test.csproj
|- packages
 \- lib
  \- RhinoMocks

Project1 项目构建成功,但 Test 项目在 ResolveAssemblyReferences 步骤中失败。相对路径似乎不正确。

[13:16:55]: [ResolveAssemblyReference] C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360, 9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Rhino.Mocks, Version=3.6.0.0, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
[13:16:55]: [ResolveAssemblyReference]         For SearchPath "{HintPathFromItem}".
[13:16:55]: [ResolveAssemblyReference]         Considered "..\packages\RhinoMocks.3.6\lib\Rhino.Mocks.dll", but it didn't exist.

TeamCity 构建配置:

  • MSBuild 任务
  • 构建文件路径:Project1.Test\Project.Test.csproj
  • 工作目录:%system.teamcity.build.checkoutDir%\Project1.Test
  • VCS 根指向上述文件夹结构的根。

据我所知,这可能是 MSBuild 问题,当我在构建代理上的 checkout 文件夹中的命令行运行 MSBuild 时,我收到相同的错误。

更多信息: 提示路径由 Nuget 包配置提供。在 Visual Studio 中,包引用可以正常工作。然而,当通过 MSBuild 运行时,它似乎对其当前目录感到困惑。 ..\packages... 路径实际上是 Nuget 的逐字引用路径。

I have set up a build in team city, with a NuGet package reference in the test project.

The folder structre I have used is

\
|- Project1
  \- Project1.csproj
|-  Project1.Test
 \- Project1.Test.csproj
|- packages
 \- lib
  \- RhinoMocks

The Project1 project builds sucessfully, but the Test project fails on the ResolveAssemblyReferences step. The relative path seems to be incorrect.

[13:16:55]: [ResolveAssemblyReference] C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360, 9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Rhino.Mocks, Version=3.6.0.0, Culture=neutral, PublicKeyToken=0b3305902db7183f, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
[13:16:55]: [ResolveAssemblyReference]         For SearchPath "{HintPathFromItem}".
[13:16:55]: [ResolveAssemblyReference]         Considered "..\packages\RhinoMocks.3.6\lib\Rhino.Mocks.dll", but it didn't exist.

TeamCity build config:

  • MSBuild task
  • Build file path: Project1.Test\Project.Test.csproj
  • Working directory: %system.teamcity.build.checkoutDir%\Project1.Test
  • VCS root points to the root of the folder structure above.

As far I can tell this may be a MSBuild issue, I get the same error when I run MSBuild at the command line in the checkout folder on the build agent.

More info:
The hint path is being provided by the Nuget package configuration. Within Visual Studio the package reference works correctly. However, when running via MSBuild, it seems confused about its current directory. The ..\packages... path is actually the verbatim reference path from Nuget.

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

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

发布评论

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

评论(2

挖个坑埋了你 2024-12-28 05:59:47

我对项目结构的这一部分感到困惑:

|- packages
 \- lib
  \- RhinoMocks

如果您从 NuGet 中提取包,则不需要这样做。 “packages”下唯一应签入源代码管理的文件是 repositories.config。

另外,当 TeamCity 运行 MSBuild 时,如何下载相关的 NuGet 依赖项?是通过 TeamCity“NuGet 安装程序”还是您已将解决方案/项目配置为自动运行 nuget 安装?

I'm confused about this part of your project structure:

|- packages
 \- lib
  \- RhinoMocks

This shouldn't be necessary if you're pulling the packages in from NuGet. The only file under "packages" that should be checked into source control is repositories.config.

Also, when TeamCity runs MSBuild, how are you downloading the relevant NuGet dependencies? Is it via the TeamCity "NuGet Installer" or have you configured your Solution/Projects to auto run nuget install?

格子衫的從容 2024-12-28 05:59:47

您有一个混合引用,具有强大的程序集名称(版本等)和提示路径。如果该程序集位于您计算机上的 GAC 中,即使提示路径错误,也将找到它。如果它不在构建计算机上的 GAC 中,则无法找到它。检查您的项目文件并查看参考上的 HintPath 元数据是否是正确的路径(看起来应该是“..\packages\lib\RhinoMocks...”,而不是输出中出现的内容。

这是一堆 ifs ,对于更多想法,我需要查看失败的项目文件中的内容。

You've got a mixed reference, with a strong assembly name (the Version etc.) and a hint path. If the assembly is in the GAC on your machine, it will be located even if the hint path is wrong. If it isn't in the GAC on the build machine, it can't be found. Check in your project file and see if the HintPath metadata on the Reference is the correct path (looks like it should be "..\packages\lib\RhinoMocks..." instead of what appears in the output.

That's a bunch of ifs, for any more ideas I'd need to see what's inside the project file that is failing.

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