public static string BuildAssemblyFromSources(string path, string baseDirectory)
        {
            if (!System.IO.Directory.Exists(path))
            {
                throw new DirectoryNotFoundException("Could not find the directory to build of " + path);
            }

            Defaults.Logger.WriteDebugMessage("Sources found in: " + path);
            var fileset = new FileSet();

            fileset = fileset.Include(new Directory(path)).RecurseAllSubDirectories.Filter("*.cs");

            string startPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "");

            string fluentBuilddll = Path.Combine(startPath, "FluentBuild.dll");

            Defaults.Logger.WriteDebugMessage("Adding in reference to the FluentBuild DLL from: " + fluentBuilddll);

            string tempPath = Environment.GetEnvironmentVariable("TEMP") + "\\FluentBuild\\" + DateTime.Now.Ticks;

            //System.IO.Directory.Delete(Environment.GetEnvironmentVariable("TEMP") + "\\FluentBuild\\", true);
            System.IO.Directory.CreateDirectory(tempPath);
            string outputAssembly = Path.Combine(tempPath, "build.dll");


            Defaults.Logger.WriteDebugMessage("Output Assembly: " + outputAssembly);

            var references = new List <String>()
            {
                fluentBuilddll
            };

            /*
             * var fluentFs = new FluentFs.Core.File(Path.Combine(startPath, "FluentFs.dll"));
             * if (File.Exists(fluentFs.ToString()))
             * {
             *  fluentFs.Copy.To(tempPath);
             *  references.Add(fluentFs.ToString());
             * }
             */

            //add in third party references
            var projectParser = new ProjectParser(path, baseDirectory);

            if (projectParser.HasProjectFile())
            {
                var referencesFromProjectFile = projectParser.GetReferences();
                foreach (var referenceFromProjectFile in referencesFromProjectFile)
                {
                    Defaults.Logger.WriteDebugMessage("Adding in third party reference " + referenceFromProjectFile);
                }
                references.AddRange(referencesFromProjectFile);
            }

            Task.Build.Csc.Target.Library(x => x.AddSources(fileset).AddRefences(references.ToArray()).IncludeDebugSymbols.OutputFileTo(outputAssembly));
            return(outputAssembly);
        }
Beispiel #2
0
        public static string BuildAssemblyFromSources(string path, string baseDirectory)
        {
            if (!System.IO.Directory.Exists(path))
                throw new DirectoryNotFoundException("Could not find the directory to build of " + path);

            Defaults.Logger.WriteDebugMessage("Sources found in: " + path);
            var fileset = new FileSet();
            fileset = fileset.Include(new Directory(path)).RecurseAllSubDirectories.Filter("*.cs");

            string startPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase).Replace("file:\\", "");

            string fluentBuilddll = Path.Combine(startPath, "FluentBuild.dll");

            Defaults.Logger.WriteDebugMessage("Adding in reference to the FluentBuild DLL from: " + fluentBuilddll);

            string tempPath = Environment.GetEnvironmentVariable("TEMP") + "\\FluentBuild\\" + DateTime.Now.Ticks;
            //System.IO.Directory.Delete(Environment.GetEnvironmentVariable("TEMP") + "\\FluentBuild\\", true);
            System.IO.Directory.CreateDirectory(tempPath);
            string outputAssembly = Path.Combine(tempPath, "build.dll");

            Defaults.Logger.WriteDebugMessage("Output Assembly: " + outputAssembly);

            var references = new List<String>() { fluentBuilddll };

            /*
            var fluentFs = new FluentFs.Core.File(Path.Combine(startPath, "FluentFs.dll"));
            if (File.Exists(fluentFs.ToString()))
            {
                fluentFs.Copy.To(tempPath);
                references.Add(fluentFs.ToString());
            }
             */

            //add in third party references
            var projectParser = new ProjectParser(path, baseDirectory);
            if (projectParser.HasProjectFile())
            {
                var referencesFromProjectFile = projectParser.GetReferences();
                foreach (var referenceFromProjectFile in referencesFromProjectFile)
                {
                    Defaults.Logger.WriteDebugMessage("Adding in third party reference " + referenceFromProjectFile);
                }
                references.AddRange(referencesFromProjectFile);
            }

            Task.Build.Csc.Target.Library(x => x.AddSources(fileset).AddRefences(references.ToArray()).IncludeDebugSymbols.OutputFileTo(outputAssembly));
            return outputAssembly;
        }