3

I have a TFS 2017 Update 2 on-prem server with VS 2017 Enterprise installed. Our Build contains a Unit-Testing project which contains a Fakes assembly and works locally on the dev machines. When build on TFS, the build fails with

The type or namespace name 'Fakes' does not exist in the namespace 'Our.Product' (are you missing an assembly reference?)

(i.e. misses/fails to generate the Our.Product.Assembly.Fakes.dll file)

I have additionally set up Fakes as suggested here.

What baffles me is that there are no mentions of Fakes in the build log (except for the error itself and the paths where MSBuild looks for the file), even with debug verbosity. He doesn't event try to generate the Fakes assembly.

Are there other steps I need to take? We use the vNext build definitions.

Update: This is the build step that works now, before the /tv:15.0 /p:VisualStudioVersion=15.0 were not there.

enter image description here

Lennart
  • 9,657
  • 16
  • 68
  • 84
  • Which build are you running XAML build or vNext build? – PatrickLu-MSFT Jul 12 '17 at 12:33
  • Fakes assemblies won't generate with VS2017 build tools installs. You may want to look at this answer at https://stackoverflow.com/questions/44156571/msbuild-15-the-type-or-namespace-fakes-does-not-exist-in-the-namespace/44928697#44928697 – zionyx Jul 12 '17 at 12:43
  • 1
    We're running vNext. @zionyx I know that answer, I even linked at it in the question. – Lennart Jul 12 '17 at 13:06

1 Answers1

3

Update

Use the latest version for msbuild arguments such as /tv:15.0 /p:VisualStudioVersion=15.0 could solve this issue.


First try to use build service account RDP to remote build agent and manually run the build to see if the assembly generated.

This will narrow down if it's related to your environment on the build agent. Make sure it's the same as your locally dev machines.

If the assembly is also generated, then the issue may related to your build definition settings. Check if you are using the right msbuild version. For vNext build, also enable verbose Debug Mode with system.debug=true

Community
  • 1
  • 1
PatrickLu-MSFT
  • 49,478
  • 5
  • 35
  • 62
  • Yes, it builds if I manually build it in VS on the remote agent. As said, there is nothing mentioned with Fakes generation in the verbose log, except the error for the missing DLL. – Lennart Jul 12 '17 at 13:33
  • 1
    @Lennart Could you share your configuration of VS build or MsBuild task, so I could give a test with it my side. Use the latest version for msbuild arguments such as `/tv:15.0 /p:VisualStudioVersion=15.0`. Also create a new build definition with the same settings and try to build the project again. – PatrickLu-MSFT Jul 12 '17 at 17:53
  • @Lennart, i manage to build with command line itself. No special parameters to generate Fakes. Here is my [logs](https://developercommunity.visualstudio.com/content/problem/70229/fake-assemblies-are-not-generated-by-using-msbuild.html?childToView=76832#comment-76832). – zionyx Jul 12 '17 at 20:21
  • @Patrick-MSFT The msbuild arguments made it work, thank you! If you add them to your answer I will accept it. I posted the MSBuild task in the question. I assumed it would automatically use MSBuild 15 because it picked up the right binary in the process. – Lennart Jul 13 '17 at 06:05
  • @Lennart Thanks, have done. Glad to here the issue fixed. According to your description, since it also builds if you manually build it in VS on the remote agent. I guess this issue may related to your tfs build definition, so suggest you to add `/tv:15.0 /p:VisualStudioVersion=15.0` which will tell msbuild force use msbuild15 and VS 2017. – PatrickLu-MSFT Jul 13 '17 at 07:04