在 TFS 下构建 CI 队列时未恢复包(VS Online VS2015)
Packages not restored when building on CI queue under TFS (VS Online VS2015)
我已经问了 并继续绝望地调查这个问题。
我猜测问题出在抓取但未正确放置的包裹上。通过查看令人痛苦的无聊日志,我得到了这个。
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.
此后不久,我看到了横盘整理的第一个迹象。
2016-01-15T21:50:43.9631666Z ##[warning]
C:\Program Files (x86)\MSBuild.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.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\s\MyStuff\MyStuff.csproj]
然后它继续考虑很多不存在的东西。
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.
...
我对 TFS 和 VS Online 上的 CI 不熟悉,所以它告诉我很少关于解决问题的地方。我用 google 搜索了自己半死,并在整个门户网站上测试了无数不同的设置。没有运气。我可能会导致其他错误(当我知道我输入了错误的东西等时),但不管怎样,我都会转向这个。
如有任何提示,我们将不胜感激。
从版本 VS2015 开始,不再需要 NuGet 文件夹,这与我看到的指南相反。事实上,唯一需要的文件是包的配置。有一种常见但非常欺骗性的 work-around 来检查包及其可执行文件,但这会在以后产生很多问题。我不推荐这样做,因为它隐藏了问题,而不是解决问题。
首先,确认您的构建确实恢复了包。我注意到在错误日志中,看起来确实如此,但这是一个陷阱。这是恢复的尝试,而不是真正的成功。如果您遇到这样的警告(对于 nUnit、WebGrease、NewtonSoft 或 NuGet 控制下的任何其他包也是如此):
Warning MSB3245: Could not resolve this reference. Could not locate the assembly "EntityFramework". Check to make sure the assembly exists on disk.
首先验证日志是否包含以下段落:
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".
请记住,当您查看日志文件时,搜索部分字符串,因为目录、版本、包名称等可能略有不同。如果您找不到它,很有可能是构建服务器上的包没有恢复。在本地编译证明环境之间存在差异,很可能文件 packages.config 不可用。这是一个棘手的错误,因为失败的日志不会告诉您它丢失了。事实上,我的日志中根本没有提到它。
- 首先,我创建了一个全新的项目Auto并签入了它。构建成功。
- 然后,我添加了 Entity Framework,构建失败并出现与您相同的警告。
- 最后,我检查了 packages.config 文件。构建成功。
出现这个问题是因为初始check-in选择了一些要忽略的文件。主要是 bin、obj 等,还有 packages.config。需要特别选择为not-ignored。如果有人签入所有文件(在我看来这不是很明智),他也会获得所需的文件,因此看起来他们做对了。请注意,您应该先将文件添加到版本控制中。这样,它会在每次更改时被签入。否则,如果您在本地添加新包或更新现有包,问题将再次出现。
如果您收到警告但包已恢复(日志中列出了行),请尝试在本地更新包或重新安装。最后,您可以通过 运行 Update-Package -Reinstall
.
从包管理器控制台刷新安装
我已经问了
我猜测问题出在抓取但未正确放置的包裹上。通过查看令人痛苦的无聊日志,我得到了这个。
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.
此后不久,我看到了横盘整理的第一个迹象。
2016-01-15T21:50:43.9631666Z ##[warning]
C:\Program Files (x86)\MSBuild.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.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\s\MyStuff\MyStuff.csproj]
然后它继续考虑很多不存在的东西。
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.
...
我对 TFS 和 VS Online 上的 CI 不熟悉,所以它告诉我很少关于解决问题的地方。我用 google 搜索了自己半死,并在整个门户网站上测试了无数不同的设置。没有运气。我可能会导致其他错误(当我知道我输入了错误的东西等时),但不管怎样,我都会转向这个。
如有任何提示,我们将不胜感激。
从版本 VS2015 开始,不再需要 NuGet 文件夹,这与我看到的指南相反。事实上,唯一需要的文件是包的配置。有一种常见但非常欺骗性的 work-around 来检查包及其可执行文件,但这会在以后产生很多问题。我不推荐这样做,因为它隐藏了问题,而不是解决问题。
首先,确认您的构建确实恢复了包。我注意到在错误日志中,看起来确实如此,但这是一个陷阱。这是恢复的尝试,而不是真正的成功。如果您遇到这样的警告(对于 nUnit、WebGrease、NewtonSoft 或 NuGet 控制下的任何其他包也是如此):
Warning MSB3245: Could not resolve this reference. Could not locate the assembly "EntityFramework". Check to make sure the assembly exists on disk.
首先验证日志是否包含以下段落:
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".
请记住,当您查看日志文件时,搜索部分字符串,因为目录、版本、包名称等可能略有不同。如果您找不到它,很有可能是构建服务器上的包没有恢复。在本地编译证明环境之间存在差异,很可能文件 packages.config 不可用。这是一个棘手的错误,因为失败的日志不会告诉您它丢失了。事实上,我的日志中根本没有提到它。
- 首先,我创建了一个全新的项目Auto并签入了它。构建成功。
- 然后,我添加了 Entity Framework,构建失败并出现与您相同的警告。
- 最后,我检查了 packages.config 文件。构建成功。
出现这个问题是因为初始check-in选择了一些要忽略的文件。主要是 bin、obj 等,还有 packages.config。需要特别选择为not-ignored。如果有人签入所有文件(在我看来这不是很明智),他也会获得所需的文件,因此看起来他们做对了。请注意,您应该先将文件添加到版本控制中。这样,它会在每次更改时被签入。否则,如果您在本地添加新包或更新现有包,问题将再次出现。
如果您收到警告但包已恢复(日志中列出了行),请尝试在本地更新包或重新安装。最后,您可以通过 运行 Update-Package -Reinstall
.