在NuGet Restore之后,MSBuild在单元测试项目(.NET Core)上失败

时间:2017-11-30 16:28:14

标签: c# asp.net msbuild continuous-integration azure-devops

ISSUE

Visual Studio Team Services中的Visual Studio Build任务构建包含默认ASP.NET MVC网站和默认单元测试项目的解决方案无法找到引用。此任务在应安装这些引用的NuGet Restore之后运行,但即使NuGet Restore任务成功,也不会在运行此构建的服务器上安装引用。

Visual Studio Team Services日志

错误日志已上传到This Github Repository

尝试修复

为了确保项目正确引用软件包,使用以下命令从软件包管理器重新安装了所有NuGet软件包:

if (serverResponse && serverResponse['vehicle']) {
    // vehicle key exists
    // do your stuff 
} else {
    // vehicle key Does Not exist
    // do your stuff 
}

这只会导致MSBuild在两个项目中都找不到PM> Update-Package --reinstall 。因此,为了解决此问题,项目中Microsoft.Net.Compilers.props的版本已删除为版本Microsoft.Net.Compilers.props。但是,这只会导致无法找到2.3.2MSTest.TestAdapter.props引用的原始错误。

1 个答案:

答案 0 :(得分:0)

尝试使用这些任务(使用您共享的示例解决方案对我来说很好):

  1. NuGet Tool Installer(要安装的NuGet.exe版本:4.3.0)
  2. NuGet恢复(选择2. *版本)
  3. Visual Studio Build(Visual Studio版本:最新)
  4. 使用安装了VS2017的代理进行队列构建。