Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k views
in Technique[技术] by (71.8m points)

c# - MSBuild 15 - The type or namespace 'Fakes' does not exist in the namespace

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:RunneruildsxxxXTests.csproj]

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

  • Source: My local VS2017 Premium Update 1 dev machine.
  • Target: The VS2017 Build Tools VM.

Copy Fakes folder:

  • From Source: c:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuildMicrosoftVisualStudiov15.0
  • To Target: c:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuildMicrosoftVisualStudiov15.0

Copy Microsoft.QualityTools.Testing.Fakes.ImportAfter.targets file:

  • From Source: c:Program Files (x86)Microsoft Visual Studio2017EnterpriseMSBuild15.0Microsoft.Common.targetsImportAfter
  • To Target: c:Program Files (x86)Microsoft Visual Studio2017BuildToolsMSBuild15.0Microsoft.Common.TargetsImportAfter

Copy Microsoft.QualityTools.Testing.Fakes.dll file:

  • From Source: c:Program Files (x86)Microsoft Visual Studio2017EnterpriseCommon7IDEPublicAssemblies
  • To Target: GAC / %windir%Microsoft.NETassembly

Builds fine now. Thanks McMlok.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...