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]
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?
To extend @McMlok's answer above, i'll include what i did.
Copy Fakes folder:
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\
Copy Microsoft.QualityTools.Testing.Fakes.ImportAfter.targets file:
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\
Copy Microsoft.QualityTools.Testing.Fakes.dll file:
c:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies\
GAC
/ %windir%\Microsoft.NET\assembly
Builds fine now. Thanks McMlok.
I have some workaround but It's not elegant.
You need to check path C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\Microsoft\VisualStudio\v15.0
if there is Fakes
folder. If not you need to install TestTools workload or copy from another machine.
Next you need to check C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Microsoft.Common.Targets\ImportAfter
if there is file Microsoft.QualityTools.Testing.Fakes.ImportAfter.targets
if not copy it from another machine. In this file is code for including fakes target to build process.
And finally you need to check if you have assembly Microsoft.QualityTools.Testing.Fakes.dll
in GAC or another location where MSBuild find it.
This I did on my build machine with MS Build Tools 2017 and now build generate fakes assemblies.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With