I don't know how to specify correct mask to search for my test assemblies in TFS2010 build definition. I'm not using default Binaries folder for output assemblies. Each test project has its own bin\Debug or bin\Release output folder. If I use the default mask **\*test*.dll my tests failed with this error:
API restriction: The assembly 'file:///E:\Builds\....\obj\Debug\xxx.IntegrationTests.dll'
has already loaded from a different location. It cannot be loaded from a new location within the same appdomain.
This is because **\*test*.dll mask will find multiple results for the same assembly in the bin\Debug and obj\Debug folders.
I tried to change this mask to exclude obj\Debug folder and use bin only:
**\bin\Debug\*test*.dll
**\bin\**\*test*.dll
**\Debug\*test*.dll
but FindMatchingFiles activity return always 0 results.
It is working only when I pass full path to the test assembly.
What is the correct mask if I want to exclude obj\Debug folders from test assembly search?
WORKAROUND:
I'm still using FindMatchingFiles activity, but I had to add Assign activity with following params:
To - testAssemblies
From - testAssemblies.Where(Function(o) Not o.Contains("\obj\")).ToList()
I'm filtering all test assemblies found in the "obj" folders this way.
The build activity that is of interest to you is named "Find Test Assemblies":
So, what you place at the build definition is concatenated after build script variable outputDirectory
.
This outputDirectory
is initialized for each configuration in activity "Initialize OutputDirectory":
You can queue a new build where you set your 'Logging Verbosity' equal to Diagnostic
. Once this has ran (and failed), check for what is going on with your build.
My guess is that you have issues with your configuration/platform settings, but without concrete input that's just guessing.
I ran into basically the same issue that you have. I have developers using a helper test assembly (TestHelper) and a _PublishedWebsites folder that was causing this issue.
What I ended up doing to fix this was solve the problem of getting multiple of the same test DLL passed to MSTest. "Well, that's what I'm trying to do with my mask," you may think! I tried that same solution but came up empty.
I wrote a custom task and inserted it after the build process finds the test assemblies. Here's the code for the custom task:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.TeamFoundation.Build.Client;
using Microsoft.TeamFoundation.Build.Workflow.Activities;
using System.Activities;
using System.IO;
namespace BuildTasks.Activities
{
[BuildActivity(HostEnvironmentOption.All)]
public class DistinctFileList : CodeActivity<IEnumerable<String>>
{
public InArgument<IEnumerable<String>> ListIn { get; set; }
protected override IEnumerable<String> Execute(CodeActivityContext context)
{
IEnumerable<string> listIn = context.GetValue(this.ListIn);
context.TrackBuildMessage("Items in ListIn: " + listIn.Count(), BuildMessageImportance.High);
var filenameGroupings = listIn.Select(filename => new FileInfo(filename.ToString()))
.GroupBy(fileInfo => fileInfo.Name);
IEnumerable<string> listOut = filenameGroupings.Select(group => group.FirstOrDefault().FullName);
context.TrackBuildMessage("Items in out list: " + listOut.Count(), BuildMessageImportance.High);
string multiples = string.Join(", ",
filenameGroupings.Where(group => group.Count() > 1).SelectMany(group => group.Select(fileInfo => fileInfo.FullName)).ToArray());
context.TrackBuildMessage("Duplicate test items: " + multiples, BuildMessageImportance.High);
return listOut.ToList();
}
}
}
You'd insert this after the "Find Test Assemblies" task.
I'm still using FindMatchingFiles activity, but I had to add Assign activity with following params:
To - testAssemblies From - testAssemblies.Where(Function(o) Not o.Contains("\obj\")).ToList() I'm filtering all test assemblies found in the "obj" folders this way.
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