【发布时间】:2013-01-04 12:12:03
【问题描述】:
我最近开始使用 NuGet 来管理外部包。现在我只需要它来处理 NLog。 当我在 VS 2012 中构建项目时,一切正常。但是,我正在尝试将 TeamCity 作为 CI 服务器(我对 CI 很陌生),它给了我以下错误:
[Csc] SomeNamespace\SomeClass.cs(10, 7): error CS0246:
The type or namespace name 'NLog' could not be found
(are you missing a using directive or an assembly reference?)
(这个错误在我使用 NLog 的地方重复出现)
现在我没有在 SVN 中包含“packages/”文件夹,因为我认为最好不要包含二进制文件,而是让 TeamCity 中的 MSBuild 自行下载这些文件。然而,它显然没有这样做。我确实在 SVN 中包含了“packages.xml”文件。 我可以检查什么以了解问题所在?
更新 感谢@DavidBrabant,我被推向了正确的方向。但是,我现在在 TeamCity 中收到以下错误:
Package restore is disabled by default. To give consent, open the Visual Studio Options dialog,
click on Package Manager node and check 'Allow NuGet to download missing packages during build.'
但是我不在 Visual Studio 中,而是在 TeamCity 中,所以我不知道如何将“同意”设置为 true!我尝试在 NuGet.targets 文件中将 RestorePackages 设置为“true”:
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
但这不起作用。
更新 2 为了使其工作,我还设置了以下属性 NuGet.targets:
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'true' ">false</RequireRestoreConsent>
这使得构建运行成功!
【问题讨论】:
-
你能从 CI 机器连接到 Nuget 存储库吗(你能 ping 通它)吗?
-
您是否启用了包恢复?
-
实际上最好的做法是在存储库中拥有构建项目所需的一切。
-
伙计,我可能真的很愚蠢,但我需要很长时间才能理解最后一个字符串必须看起来像
<RequireRestoreConsent Condition=" '$(RequireRestoreConsent)' != 'true' ">false</RequireRestoreConsent>我认为指定正确的字符串而不是初始字符串是有意义的它的版本。 -
谢谢 Seekeer,我相应地改了!
标签: c# windows-services teamcity nuget .net-4.5