Loading an assembly from a specific path, including all sub dependencies

    public static class AssemblyLoader
        private static readonly ConcurrentDictionary<string, bool> AssemblyDirectories = new ConcurrentDictionary<string, bool>();

        static AssemblyLoader()
            AssemblyDirectories[GetExecutingAssemblyDirectory()] = true;
            AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;


        public static Assembly LoadWithDependencies(string assemblyPath)
            AssemblyDirectories[Path.GetDirectoryName(assemblyPath)] = true;
            return Assembly.LoadFile(assemblyPath);

        private static Assembly ResolveAssembly(object sender, ResolveEventArgs args)
            string dependentAssemblyName = args.Name.Split(’,’)[0] + ".dll";
            List<string> directoriesToScan = AssemblyDirectories.Keys.ToList();

            foreach (string directoryToScan in directoriesToScan)
                string dependentAssemblyPath = Path.Combine(directoryToScan, dependentAssemblyName);
                if (File.Exists(dependentAssemblyPath))
                    return LoadWithDependencies(dependentAssemblyPath);
            return null;

        private static string GetExecutingAssemblyDirectory()
            string codeBase = Assembly.GetExecutingAssembly().CodeBase;
            var uri = new UriBuilder(codeBase);
            string path = Uri.UnescapeDataString(uri.Path);
            return Path.GetDirectoryName(path);


Running dotnet core xUnit tests on Visual Studio Team Services (VSTS)

1: Run dotnet restore to restore package dependencies.

2: Run dotnet build to build the binaries.

3: Run dotnet test to run the tests. Note the additional parameters --no-build to prevent a rebuild and --logger "trx;LogFileName=tests-log.trx" to ensure the test results are written to disk,

5: Use  a Publish Test Results tasks to output the results of the tests. Make sure you set the following properties
  • Test Result Format = VSTest
  • Test Results Files = **/tests-log.trx
And under the Advanced section make sure you set the Run This Task option so that it will run even if the previous task failed.


Get list of object keys in Angular

import { PipeTransform, Pipe } from "@angular/core";
@Pipe({ name: 'keys' })
export class KeysPipe implements PipeTransform {
  transform(value, args:string[]) : any {
    let keys = [];
    for (let key in value) {
      keys.push({key: key, value: value[key]});
    return keys;

Then to get a list of errors for a form element you can do this

<ul *ngIf="form.get('userName').invalid" class="help-block with-errors">
   <li *ngFor="let error of form.get('userName').errors | keys">{{ error.key }}</li>