Welcome toVigges Developer Community-Open, Learning,Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to Vigges Developer Community for programmer and developer-Open, Learning and Share

2.1m questions

2.1m answers

63 comments

56.7k users

...