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

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

问题描述

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

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): error CS0234: The type or namespace 'Fakes' does not exist in the namespace 'System.Data.Common' (are you missing an assembly reference?) [C:\Runner\builds\xxx\XTests.csproj]

根据我的研究,这是由于使用了旧版本的MSBuild引起的,但是我已经检查了服务器,并确认它具有最新版本的&已安装Visual Studio的更新.我还确认生成脚本使用的是正确版本的MSBuild.exe,即c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.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 Studio\2017\Enterprise\MSBuild\15.0\Bin\MSBuild.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构建工具VM.

复制 Fakes 文件夹:

  • 来源:c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\
  • 定位:c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\
  • From Source: c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0\
  • To Target: c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\Microsoft\VisualStudio\v15.0\

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

  • 来源:c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\
  • 定位:c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Microsoft.Common.Targets\ImportAfter\
  • From Source: c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.targets\ImportAfter\
  • To Target: c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Microsoft.Common.Targets\ImportAfter\

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

  • 来源:c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\
  • 要定位:GAC/%windir%\Microsoft.NET\assembly
  • From Source: c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\
  • To Target: GAC / %windir%\Microsoft.NET\assembly

现在构建良好.谢谢McMlok.

Builds fine now. Thanks McMlok.

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

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