在 TFS 下构建 CI 队列时包未恢复(VS Online VS2015) [英] Packages not restored when building on CI queue under TFS (VS Online VS2015)

查看:9
本文介绍了在 TFS 下构建 CI 队列时包未恢复(VS Online VS2015)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我问过 关于构建错误的问题 并继续以我绝望的自我进一步调查这个问题.

I've asked a question about build errors and continued investigating the issue further by my desperate self.

我猜测问题出在已获取但未正确放置的包上.浏览令人痛苦的无聊日志给了我这个.

I have a guesstimation that the issue is about the packages that are fetched but not placed correctly. Looking through the painfully boring logs gave me this.

2016-01-15T21:50:40.8680146Z
C:Program Files (x86)MSBuildMicrosoftNuGetMicrosoft.NuGet.targets (186,61)"的 BeforeTargets 属性中列出的目标BeforeGenerateProjectPriFile"在项目中不存在,将被忽略.

2016-01-15T21:50:40.8680146Z
The target "BeforeGenerateProjectPriFile" listed in a BeforeTargets attribute at "C:Program Files (x86)MSBuildMicrosoftNuGetMicrosoft.NuGet.targets (186,61)" does not exist in the project, and will be ignored.

不久之后,我可以看到有什么东西在横向移动的第一个迹象.

Shortly thereafter, I can see the first sign of something going sideways.

2016-01-15T21:50:43.9631666Z ##[警告]
C:Program Files (x86)MSBuild14.0inMicrosoft.Common.CurrentVersion.targets(1819,5):警告 MSB3245:无法解析此引用.找不到程序集Microsoft.CodeDom.Providers.DotNetCompilerPlatform,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL".检查以确保该程序集存在于磁盘上.如果您的代码需要此引用,则可能会出现编译错误.
2016-01-15T21:50:43.9631666Z 2>
C:Program Files (x86)MSBuild14.0inMicrosoft.Common.CurrentVersion.targets(1819,5):警告 MSB3245:无法解析此引用.找不到程序集Microsoft.CodeDom.Providers.DotNetCompilerPlatform,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL".检查以确保该程序集存在于磁盘上.如果您的代码需要此引用,您可能会遇到编译错误.[C:a1sMyStuffMyStuff.csproj]

2016-01-15T21:50:43.9631666Z ##[warning]
C:Program Files (x86)MSBuild14.0inMicrosoft.Common.CurrentVersion.targets(1819,5): Warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
2016-01-15T21:50:43.9631666Z 2>
C:Program Files (x86)MSBuild14.0inMicrosoft.Common.CurrentVersion.targets(1819,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.CodeDom.Providers.DotNetCompilerPlatform, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [C:a1sMyStuffMyStuff.csproj]

然后它继续大量考虑不存在的东西.

And then it continues a lot about considering stuff that aren't existing.

2016-01-15T21:50:43.9661661Z
考虑..packagesMicrosoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0lib et45Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll",但它不存在.
2016-01-15T21:50:43.9671655Z
对于 SearchPath{TargetFrameworkDirectory}".2016-01-15T21:50:43.9681655Z
考虑为C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5.2Microsoft.CodeDom.Providers.DotNetCompilerPlatform.winmd",但它不存在.
...

2016-01-15T21:50:43.9661661Z
Considered "..packagesMicrosoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0lib et45Microsoft.CodeDom.Providers.DotNetCompilerPlatform.dll", but it didn't exist.
2016-01-15T21:50:43.9671655Z
For SearchPath "{TargetFrameworkDirectory}". 2016-01-15T21:50:43.9681655Z
Considered "C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5.2Microsoft.CodeDom.Providers.DotNetCompilerPlatform.winmd", but it didn't exist.
...

我不熟悉 TFS 或 VS Online 上的 CI,因此它很少告诉我在哪里解决问题.我已经用谷歌搜索了半死,并在整个门户网站上测试了无数种不同的设置.没有运气.我可能会导致其他错误(当我知道我输入了错误的内容等时),但无论如何,我都会转向这个.

I'm not familiar with CI on TFS nor VS Online so it tells me very little about where to strike on the problem. I've googled myself half to death and tested a gazillion of different settings all over the portal. No luck. I can cause other errors (when I know that I'm typing in wrong stuff etc.) but one way or the other, I revolve to this one.

任何提示将不胜感激.

推荐答案

从 VS2015 版本开始,不需要 NuGet 文件夹,与我看到的指南相反.事实上,唯一需要的文件是包的配置.检查软件包及其可执行文件有一种常见但非常具有欺骗性的解决方法,但这可能会在未来产生很多问题.我不建议这样做,因为它隐藏了问题,而不是解决它.

Starting with version VS2015, there's no need for NuGet folder, contrary to the guides that I've seen. In fact, the only file that's needed is the config with the packages. There's the common but very deceitful work-around to check in the packages and their executables but that can create a lot of issues down the road. I wouldn't recommend that because it's hiding the problem, not resolving it.

首先,验证您的构建是否确实恢复了包.我注意到在错误日志中,它看起来是这样,但这是一个陷阱.这是一种恢复的尝试,而不是真正的成功.如果您遇到这样的警告(对于 nUnit、WebGrease、NewtonSoft 或 NuGet 控制下的任何其他包也是如此):

First, verify that your build actually restores the packages. I noticed that in the error logs, it looks like if it does but that's a pitfall. It's an attempt to restore, not the actually success. If you encounter a warning like this (and the same goes for nUnit, WebGrease, NewtonSoft or any other package under NuGet's control):

警告 MSB3245:无法解析此引用.找不到程序集EntityFramework".检查以确保该程序集存在于磁盘上.

Warning MSB3245: Could not resolve this reference. Could not locate the assembly "EntityFramework". Check to make sure the assembly exists on disk.

首先验证日志是否包含以下段落:

start by verifying that the logs contain the following passages:

PrepareForBuild:
创建目录objDebug".
...
恢复包:
"C:asrcsrc.nuget uget.exe" 安装 "C:asrcsrcxxxx.Entitiespackages.config"
-source -RequireConsent -o "C:asrcsrcpackages"
...
成功安装EntityFramework 6.3.1".解决AssemblyReferences:
主要参考EntityFramework".

PrepareForBuild:
Creating directory "objDebug".
...
RestorePackages:
"C:asrcsrc.nuget uget.exe" install "C:asrcsrcxxxx.Entitiespackages.config"
-source -RequireConsent -o "C:asrcsrcpackages"
...
Successfully installed "EntityFramework 6.3.1". ResolveAssemblyReferences:
Primary reference "EntityFramework".

请记住,在查看日志文件时,请搜索部分字符串,因为目录、版本、包名称等可能会略有不同.如果你找不到它,很有可能软件包没有在构建服务器上恢复.本地编译证明环境之间存在差异,很可能文件 packages.config 不可用.这是一个棘手的错误,因为失败的日志不会告诉您它丢失了.事实上,我的日志中根本没有提到它.

Keep in mind that when you look through the log files, search for partial strings, since the directories, versions, packages' names etc. can vary slightly. If you can't find it, there's a good chance that the packages aren't restored on the build server. Compiling locally proves that there's a difference between environments, most likely the file packages.config isn't available. It's a tricky error because the failed logs won't tell you that it's missing. In fact, I haven't it mentioned at all in my logs.

  1. 首先,我创建了一个全新的项目Auto并签入.构建成功.
  2. 然后,我添加了 Entity Framework,构建失败并出现与您相同的警告.
  3. 最后,我签入了 packages.config 文件.构建成功.
  1. First, I created a brand new project Auto and checked it in. The build succeeded.
  2. Then, I added Entity Framework and the build failed with the same warning as yours.
  3. Finally, I checked in the packages.config file. The build succeeded.

出现此问题的原因是初始签入选择了许多要忽略的文件.主要是 binobj 等,还有 packages.config.需要具体选择为不忽略.如果有人签入所有文件(在我看来不是很明智),他也会得到所需的文件,所以看起来他们做得对.请注意,您应该先将文件添加到版本控制中.这样,每次更改都会检查它.否则,如果您在本地添加新包或更新现有包,问题将重新出现.

The problem occurs because the initial check-in selects a number of files to ignore. Mostly it's the bin, obj etc. but also the packages.config. It needs to be specifically selected as not-ignored. If someone checks in all the files (not very wise, in my view), he also gets the file needed and so it appears like if they're doing it right. Please note that you should add the file to the version control first. That way, it's being checked in at each change. Otherwise, the issues will start to reappear if you add a new package locally or if you update an existing one.

如果您收到警告但软件包已恢复(日志中列出了行),请尝试在本地更新软件包或重新安装它.最后,您可以通过运行 Update-Package -Reinstall 从包管理器控制台刷新安装.

If you get the warning but the packages are restored (the logs have the lines listed), try to update the package locally or reinstall it. Finally, you could refresh the installation from the package manager console by running Update-Package -Reinstall.

  • 与旧版本的包管理器类似的问题 这里.
  • 关于需要签入的文件的错误建议(自 VS 2015 起)此处.
  • 文件布局的过时描述(适用于 VS 2013 及更早版本)这里.
  • 有关如何构建 NuGet 文件结构的更多信息此处.
  • 关于这个问题的非常好的博客(奇怪的是它没有出现在谷歌的顶部)这里.

这篇关于在 TFS 下构建 CI 队列时包未恢复(VS Online VS2015)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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