在TFS下的CI队列上构建时不还原包(VS Online VS2015) [英] Packages not restored when building on CI queue under TFS (VS Online VS2015)

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

问题描述

我要求



出现此问题是因为初始检入选择了要忽略的多个文件。主要是 bin obj 等,还有 packages.config 。它需要被特别选择为不忽略。如果有人检查所有的文件(不是很明智,在我看来),他还得到所需的文件,所以它看起来好像他们做的正确。请注意,您应该首先将文件添加到版本控制。这样,它在每次更改时签入。否则,如果您在本地添加新包或更新现有包,则问题将重新出现。



如果您收到警告,但包裹已还原日志具有列出的行),请尝试在本地更新程序包或重新安装。最后,您可以通过运行 Update-Package -Reinstall 从包管理器控制台刷新安装。




  • 与旧版本的软件包管理器类似的问题此处

  • 需要签入(自2015年以来)此处

  • 过时的说明文件布局(适用于VS 2013及更早版本)此处

  • 有关NuGet文件结构的详细信息此处

  • 很好的博客上的问题(奇怪,它不会出现在谷歌的顶部)此处


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
The target "BeforeGenerateProjectPriFile" listed in a BeforeTargets attribute at "C:\Program Files (x86)\MSBuild\Microsoft\NuGet\Microsoft.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 ##[warning]
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.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)\MSBuild\14.0\bin\Microsoft.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:\a\1\s\MyStuff\MyStuff.csproj]

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

2016-01-15T21:50:43.9661661Z
Considered "..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.0\lib\net45\Microsoft.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 Assemblies\Microsoft\Framework.NETFramework\v4.5.2\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.winmd", but it didn't exist.
...

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.

Any hints would be appreciated.

解决方案

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.

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):

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:
Creating directory "obj\Debug\".
...
RestorePackages:
"C:\a\src\src.nuget\nuget.exe" install "C:\a\src\src\xxxx.Entities\packages.config"
-source -RequireConsent -o "C:\a\src\src\packages"
...
Successfully installed "EntityFramework 6.3.1". ResolveAssemblyReferences:
Primary reference "EntityFramework".

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. 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.

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.

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.

  • Similar issue with an older version of Package Manager here.
  • Incorrect advice on the files that need to be checked in (since VS 2015) here.
  • Outdated description of the file layout (valid for VS 2013 and earlier) here.
  • More info on how NuGet files structure is built up here.
  • Very good blog on the issue (strange that it doesn't come up at top in Google) here.

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

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