0

I have a solution with bunch of C# projects with bunch of tests. Some of these tests require few native dlls (provided by related nuget packages). To address this .testsettings file was created that is copying dlls (that nuget coped to $(OutDir)) to test directory before running tests.

All this works fine on local machine, but when executed under TFS Build 'deployment' section of .testsettings file (or maybe entire file) gets ignored -- these dlls never materialize in test directory (nor there are any entries in the logs about them). .testsettings file is mentioned in related section of TFS build configuration.

Any ideas what could be wrong? (MSVC 2015, TFS 2013)

C.M.
  • 3,071
  • 1
  • 14
  • 33
  • I tried what you did above and I found that the .testsetting file copy the dlls were copied to the folder "C:\agent\_work\46\TestResults\*******\Out". Does this path to be the “test directory” you mentioned above or you want those dlls to be copied to another path? – Tingting0929 Mar 02 '17 at 09:24
  • I'm using the Visual Studio Test step. Yes, there's no log record about copy these dlls. – Tingting0929 Mar 02 '17 at 09:25
  • Yes, I copy (via deployment section of .testsettings file) few dlls from $(OutDir) to "...\TestResults\...\Out". It works fine when I do it locally (from Visual Studio). Doesn't work when build is executed by TFS (all tests that don't depend on these dlls work just fine). – C.M. Mar 03 '17 at 17:36
  • Did you keep monitoring the "TestResult\..\Out\" folder on your build agent server when test runs? Are those dlls copied to the folder and then deleted or it never be copied to? – Tingting0929 Mar 06 '17 at 05:24
  • As a workaround, you could use the "Copy Files" steps to copy those dlls to the folder you want instead of using the .testsetting file to do this. – Tingting0929 Mar 06 '17 at 05:26
  • As far as I could see they never get copied. Yes, I guess, I'll have to add extra steps to TFS build process. Thank you – C.M. Mar 07 '17 at 05:56

2 Answers2

0

Have you try to see if they are installed on your TFS server? Did you check on GAC of the TFS server if they are registered?

Bellow is an explanation of how I deal with my dependencies, hope it helps.

This is my HMO about this topic. Must of the time I avoid to give the responsibility to the TFS to restore the NuGet packages in a separate folder. How I do that?

1- I create a separate folder at the level of my project. (Common)

enter image description here

If you see on the bottom there is a Nuget.config file. Bellow is the configuration it has

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <config>
    <add key="repositoryPath" value="$\..\Common\Packages" />
  </config>
</configuration>

Now all my Packages are hosted inside Common folder. Now, place all you extra dlls there in a separate folder if you need. If you depend on native dlls that are hosted on the GAC, then you should take a look on the TFS Server if those are installed there. With that said, I put all my project reference pointing to my Common folder, even my Nuget Repository is getting the files from that location also.

enter image description here

The advantage:

  1. you centralize all your dlls(remember if you depend on a Native dlls, you should install on the TFS the version of the Framework you need in order to run the MSBuild correctly)
  2. all projects point to the same dependencies
  3. you just mantain the Common folder.
  4. Once you check-in a package inside the Common folder, you are guaranteeing that the dependency is also hosted on the TFS, and when the MSBuild runs it can find them.
Zinov
  • 3,817
  • 5
  • 36
  • 70
  • Yes, packages are installed just fine. And during build related dlls get copied to $(OutDir). But then (when tests are executed) they aren't get copied to test directory (as stipulated by deployment section in my .testsettings file). Looks like a bug somewhere in MS tools. – C.M. Mar 02 '17 at 02:24
0

For TFS 2013, it only has XAML build. For XAML build, the testsetting file couldn't copy the assemblies from Nuget package $(OutDir) to the C:\Builds\...\builddefinition\...\TestSetting(tst)\...\Out folder before tests run.

I suggest that you could upgrade your TFS to TFS 2015 or upper version to use VNext build. And I have already tested that in Vnext build, it works. This is my build definition example: just add 3 steps. enter image description here

Tingting0929
  • 4,142
  • 1
  • 14
  • 14
  • Any idea how to figure out where to copy these files to? I don't know how test directory name gets generated. – C.M. Mar 09 '17 at 03:34
  • @C.M. In your build definition, did you add a Nuget install step at the beginning of your build definition? In your build agent server, is there a "Package" folder under the path: C:\...\agent\_work\46\s\DefinitionName? – Tingting0929 Mar 14 '17 at 08:31
  • Not sure, can't access build machine now. But likely not -- Visual Studio installs missing nuget packages automatically as part of the build (if nuget version is high enough) -- so there is no need to configure anything related to it in the build def. – C.M. Mar 15 '17 at 15:21
  • Uhm... You are still confusing things. I don't need to copy stuff from nuget package to Out folder. Nuget packages get deployed just fine and required dlls appear in $Out folder just fine. I need some these dlls to be copied in to test folder (where tests get executed) before testing gets kicked off. Anyways, I gave up on this thing. Seems like a bug in TFS, waiting for few dependencies to get fixed and will upgrade to TFS 2015. – C.M. Mar 16 '17 at 05:27
  • @C.M. The Out folder I mean is not refer to the path `"C:\Builds\...\TestSetting\...\Out"` not the $(OutDir) of Nuget packages. I have edited my reply. And after you upgrade to TFS 2015, you could use TFS Vnext build, this is fixed in VNext build. – Tingting0929 Mar 16 '17 at 08:06