예제 #1
0
        internal override IEnumerable <RegisteredTask> LoadPlugins()
        {
            AppDomain.CurrentDomain.AssemblyResolve += ResolveAssembly;

            IEnumerable <string> cakeTasksDirs = AddinFinder.Find(PluginsDir);

            foreach (string cakeTasksDir in cakeTasksDirs)
            {
                //TODO: Need to support for framework targets
                string dllDir = Path.Combine(cakeTasksDir, "lib", "netstandard2.0");
                if (!Directory.Exists(dllDir))
                {
                    continue;
                }

                string[] dllFiles = Directory.GetFiles(dllDir, "*.dll", SearchOption.TopDirectoryOnly);

                foreach (string dllFile in dllFiles)
                {
                    IEnumerable <RegisteredTask> dllPlugins = FindPlugins(dllFile);
                    foreach (RegisteredTask dllPlugin in dllPlugins)
                    {
                        yield return(dllPlugin);
                    }
                }
            }
        }
예제 #2
0
        private void InitializeConfiguration()
        {
            // Setup action to initialize some really core stuff, including directories and version
            // details.
            RegisterSetupAction(ctx =>
            {
                Log.Verbose("Initializing Cake.Tasks configuration.");

                TaskConfig config = TaskConfig.Current;

                EnvConfig env = config.Load <EnvConfig>();
                env.Name      = Path.GetFileName(ctx.Environment.WorkingDirectory.FullPath)
                                .Replace('.', '-')
                                .Replace(' ', '-')
                                .Replace('_', '-')
                                .Trim();
                env.Configuration = ctx.Arguments.GetArgument("Configuration") ?? "Release";
                env.IsCi          = false;
                env.Branch        = null;

                env.Directories.Working       = ctx.Environment.WorkingDirectory.FullPath;
                string outputDirectory        = Path.Combine(env.Directories.Working, ".ci");
                env.Directories.Artifacts     = Path.Combine(outputDirectory, "artifacts");
                env.Directories.BinaryOutput  = Path.Combine(outputDirectory, "binaries");
                env.Directories.PublishOutput = Path.Combine(outputDirectory, "publish");
                env.Directories.TestOutput    = Path.Combine(outputDirectory, "testresults");

                env.Version.BuildNumber = "1";
                env.Version.Primary     = (Func <string>)(() => $"0.{env.Version.BuildNumber.Resolve()}.0");
                env.Version.Full        = (Func <string>)(() => env.Version.Primary.Resolve());
                env.Version.Build       = (Func <string>)(() => $"{env.Version.Full.Resolve()}+{env.Version.BuildNumber.Resolve()}");

                // Display the subdirectories under the tools/Addins directory.
                // To verify the versions of the addins and tools installed.
                // Useful for troubleshooting.
                //TODO: Make this a configuration
                ctx.LogHighlight("--------------------");
                ctx.LogHighlight("Addin subdirectories");
                ctx.LogHighlight("--------------------");
                string addinsBaseDir = Path.Combine(env.Directories.Working, "tools", "Addins");
                if (Directory.Exists(addinsBaseDir))
                {
                    IEnumerable <string> addinsDirs = AddinFinder.Find(addinsBaseDir);
                    IEnumerable <string> otherDirs  = Directory.EnumerateDirectories(addinsBaseDir, "*", SearchOption.TopDirectoryOnly)
                                                      .Except(addinsDirs, StringComparer.OrdinalIgnoreCase);
                    foreach (string addinsDir in addinsDirs)
                    {
                        ctx.LogHighlight(Path.GetFileName(addinsDir));
                    }
                    foreach (string otherDir in otherDirs)
                    {
                        ctx.Log.Information(Path.GetFileName(otherDir));
                    }
                }

                return(config);
            });
        }