//The engine calls this method to resolve assembly references used in
        //the generated transformation class project and for the optional
        //assembly directive if the user has specified it in the text template.
        //This method can be called 0, 1, or more times.
        //---------------------------------------------------------------------
        public string ResolveAssemblyReference(string assemblyReference)
        {
            //If the argument is the fully qualified path of an existing file,
            //then we are done. (This does not do any work.)
            //----------------------------------------------------------------
            if (File.Exists(assemblyReference))
            {
                return(assemblyReference);
            }

            var assemblyReferenceFile = $"{assemblyReference}.dll";

            //If the argument is the fully qualified path of an existing file,
            //then we are done. (This does not do any work.)
            //----------------------------------------------------------------
            if (File.Exists(assemblyReferenceFile))
            {
                return(assemblyReferenceFile);
            }

            //Maybe the assembly is in the same folder as the text template that
            //called the directive.
            //----------------------------------------------------------------
            var file      = TemplateFile?.IsFilled() == true ? TemplateFile : "./test.tmp";
            var folder    = Path.GetDirectoryName(file);
            var candidate = Path.Combine(folder?.IsFilled() == true ? folder : ".", assemblyReferenceFile);

            if (File.Exists(candidate))
            {
                return(candidate);
            }

            //Maybe the assembly is in the same folder as the executing Assembly
            //----------------------------------------------------------------
            candidate = Path.Combine(Path.GetDirectoryName(new Uri(Assembly.GetExecutingAssembly().CodeBase).LocalPath) ?? ".", assemblyReferenceFile);

            if (File.Exists(candidate))
            {
                return(candidate);
            }

            //This can be customized to search specific paths for the file
            //or to search the GAC.
            //----------------------------------------------------------------
            //This can be customized to accept paths to search as command line
            //arguments.
            //----------------------------------------------------------------
            //If we cannot do better, return the original file name.

            var assemblyPath = AppDomain.CurrentDomain.GetAssemblies().
                               FirstOrDefault(assembly => assembly.GetName().Name == assemblyReference.Split(',').FirstOrDefault())?.CodeBase;

            return(assemblyPath == null ? "": new Uri(assemblyPath).LocalPath);
        }