MSBuild 15 - 命名空间中不存在类型或命名空间“Fakes" [英] MSBuild 15 - The type or namespace 'Fakes' does not exist in the namespace

查看:37
本文介绍了MSBuild 15 - 命名空间中不存在类型或命名空间“Fakes"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为使用 Fakes 库进行单元测试的项目设置自动构建和单元测试.该项目在我的 Windows 10 PC(安装了 VS 2017 Enterprise)上构建和测试良好,但是使用相同的命令在构建服务器上编译项目(也是带有 VS 2017 Enterprise 的 Windows 10)给出了几个关于 Fakes 不存在的错误.确切的错误如下所示:

I'm trying to set up automated builds and unit testing for a project which uses the Fakes library for it's unit tests. The project builds and tests fine on my Windows 10 PC (VS 2017 Enterprise installed), however using the same command to compile the project on the build server (also windows 10 with VS 2017 Enterprise) gives several errors about the Fakes not existing. The exact errors look like this:

XControllerTests.cs(10,20):错误 CS0234:命名空间System.Data.Common"中不存在类型或命名空间Fakes"(您是否缺少程序集引用?)[C:RunneruildsxxxXTests.csproj]

根据我的研究,这是由使用旧版本的 MSBuild 引起的,但是我检查了服务器,并确认它具有最新版本 &安装了 Visual Studio 的更新.我还确认构建脚本使用的是正确版本的 MSBuild.exe,即 c:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe.在我的桌面上使用这个版本可以正确编译项目.

From my research, this is caused by using an old version of MSBuild, however I have checked the server, and confirmed it has the latest version & updates for visual studio installed. I also confirmed that the build script is using the correct version of MSBuild.exe, which is c:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0BinMSBuild.exe. Using this version on my desktop correctly compiles the project.

为什么构建不能在(相同设置)构建服务器上工作?

Why does the build not work on the (identical setup) build server?

推荐答案

为了扩展上面@McMlok 的答案,我将包括我所做的.

To extend @McMlok's answer above, i'll include what i did.

  • 来源:我的本地 VS2017 Premium Update 1 开发机器.
  • 目标:VS2017 Build Tools VM.

复制Fakes文件夹:

  • 来源:c:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuildMicrosoftVisualStudiov15.0
  • 目标:c:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuildMicrosoftVisualStudiov15.0

复制 Microsoft.QualityTools.Testing.Fakes.ImportAfter.targets 文件:

  • 来源:c:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0Microsoft.Common.targetsImportAfter
  • 到目标:c:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuild15.0Microsoft.Common.TargetsImportAfter

复制 Microsoft.QualityTools.Testing.Fakes.dll 文件:

  • 来源:c:Program Files (x86)Microsoft Visual Studio2017EnterpriseCommon7IDEPublicAssemblies
  • 到目标:GAC/%windir%Microsoft.NETassembly

现在构建良好.谢谢麦克姆洛克.

Builds fine now. Thanks McMlok.

这篇关于MSBuild 15 - 命名空间中不存在类型或命名空间“Fakes"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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