Ejemplo n.º 1
0
        string Compile(ScriptPath spath, bool tapwasupdated)
        {
            string path = spath.Path;

            if (!File.Exists(path))
            {
                throw new FileNotFoundException("source file not found", path);
            }
            string outpath = TapFromSource(spath);
            string pdbpath = PdbFromTap(outpath);

            string[] sa = GetSubjectAssemblies(); // this includes tap.exe copied with CopyMe
            TAPApp.VLog(3, "subject assemblies:" + string.Join(",", sa.ToArray()));
            if (!tapwasupdated && !TAPApp.IsOutdated(outpath, path) && !TAPApp.IsOutdated(pdbpath, path) &&
                !IsOutdated(outpath, sa))
            {
                TAPApp.VLog(2, outpath + " is up to date");
                return(outpath);
            }
            TAPApp.VLog(3, "building {0}", outpath);
            using (CodeDomProvider prov = new CSharpCodeProvider(new Dictionary <string, string> {
                { "CompilerVersion", "v3.5" }
            })) {                                       // maybe make configurable in a <system.codedom><compilers>...
                var cp = new CompilerParameters();
                cp.GenerateExecutable      = true;
                cp.IncludeDebugInformation = true;
                cp.OutputAssembly          = outpath;
                //cp.CompilerOptions+=String.Concat("/d:DEBUG /lib:\"",GetMyImagePath(),"\"");
#if __MonoCS__
                cp.CompilerOptions += "/d:DEBUG /nowarn:169";
#else
                cp.CompilerOptions += string.Concat("/d:DEBUG /pdb:", pdbpath);
#endif
                cp.ReferencedAssemblies.Add("System.dll");
                cp.ReferencedAssemblies.Add("System.Core.dll");

                cp.ReferencedAssemblies.AddRange(sa);
                cp.ReferencedAssemblies.AddRange(TAPApp.Refs.ToArray());
                CompilerResults cr     = prov.CompileAssemblyFromFile(cp, new [] { path });
                bool            errors = cr.Errors.Count > 0;
                if (errors)
                {
                    TAPApp.ELog("Errors building");
                }
                if (errors || TAPApp.Verbose > 1)
                {
                    foreach (string i in cr.Output)
                    {
                        TAPApp.Log(i);
                    }
                }
                if (!errors)
                {
                    return(cr.PathToAssembly);
                }
                return(null);
            }
        }
Ejemplo n.º 2
0
        static bool IsOutdated(string obj, string[] src)
        {
            string first = src.FirstOrDefault(x => TAPApp.IsOutdated(obj, x));

            if (first != null)
            {
                TAPApp.VLog(2, "{0} is newer than {1}", first, obj);
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
        bool CopyMe(string targetpath)
        {
            string me = GetMyImagePath();
            string to = Path.Combine(targetpath, Path.GetFileName(me));

            if (TAPApp.IsOutdated(to, me))
            {
                TAPApp.VLog(2, "copy from {0} to {1}", me, to);
                File.Copy(me, to, true);
                // this can be removed once all the bugs are fixed :-)
                string pdb   = TAPApp.PdbFromExe(me);
                string pdbto = TAPApp.PdbFromExe(to);
                File.Copy(pdb, pdbto, true);
                return(true);
            }
            return(false);
        }