Esempio n. 1
0
        /// <summary>
        /// Compiles the Visual Basic project or project group.
        /// </summary>
        protected override void ExecuteTask()
        {
            Log(Level.Info, "Building project '{0}'.", ProjectFile.FullName);
            if (NeedsCompiling())
            {
                //Using a stringbuilder vs. StreamWriter since this program will
                // not accept response files.
                StringBuilder writer = new StringBuilder();

                writer.AppendFormat(" /make \"{0}\"", ProjectFile.FullName);

                // make sure the output directory exists
                if (!OutDir.Exists)
                {
                    OutDir.Create();
                }

                if (Conditionals != null)
                {
                    writer.AppendFormat(" /d {0}", _conditionals);
                }

                writer.AppendFormat(" /outdir \"{0}\"", OutDir.FullName);

                if (ErrorFile != null)
                {
                    writer.AppendFormat(" /out \"{0}\"", ErrorFile.FullName);
                }

                _programArguments = writer.ToString();

                // call base class to do the work
                base.ExecuteTask();
            }
        }
Esempio n. 2
0
        protected override void Execute(CodeActivityContext context)
        {
            console = context.GetExtension <ActivityConsole>();
            if (console == null)
            {
                console = new ActivityConsole();
            }

            if (!string.IsNullOrEmpty(CommandLineArguments.Get(context)))
            {
                console.WriteLine("!!!Warning - This activity currently ignores 'CommandLineArguments' argument. !!!");
            }

            var project = new Project(Project.Get(context));
            StringOutputLogger logger = new StringOutputLogger();

            project.SetGlobalProperty("Configuration", Configuration.Get(context) ?? "");
            project.SetGlobalProperty("Platform", Platform.Get(context) ?? "");
            project.SetProperty("OutDir", OutDir.Get(context) ?? "");
            bool   buildResult = project.Build(Targets.Get(context).ToArray(), new ILogger[] { logger });
            string buildOutput = string.Format(
                "MSBUILD - {0}\nConfiguration : {1}\nPlatform : {2}\nOutput Directory : {3}\n{4}",
                project.FullPath,
                project.GetProperty("Configuration").EvaluatedValue,
                project.GetProperty("Platform").EvaluatedValue,
                project.GetProperty("OutDir").EvaluatedValue,
                logger.GetOutput());

            BuildOutput.Set(context, buildOutput);
            BuildSuccess.Set(context, buildResult);
            ProjectCollection.GlobalProjectCollection.UnloadProject(project);

            console.WriteLine(buildOutput);
        }
 public void assembly_is_compiled()
 {
     OutDir.GetFile("MyProject.dll").Exists.ShouldBeTrue();
 }
Esempio n. 4
0
        public void LoadConf(XmlNode root)
        {
            XmlNode xn = null;

            try
            {
                // 读取显示属性

                log.WriteFileLog("读取产品信息");

                type       = root.Attributes["type"].InnerText;
                product_id = root.Attributes["product_id"].InnerText;
                enable     = bool.Parse(root.Attributes["enable"].InnerText);
                name       = root.Attributes["name"].InnerText;
                funclist   = root.Attributes["funclist"].InnerText;

                // 读取节点配置明细
                log.WriteFileLog("读取配置库信息");
                xn         = root.SelectSingleNode("Repository");
                Repository = xn.Attributes["repo"].InnerText;
                WorkSpace  = xn.Attributes["workspace"].InnerText;
                // OutDir 如果以 \ 结尾,会导致编译前台Drp时,批处理里会出现 "C:\src\", \"会被认为是转义,就报错了,
                // 这里如果,结尾是\,去掉
                if (WorkSpace[WorkSpace.Length - 1] == '\\')
                {
                    WorkSpace = WorkSpace.Substring(0, WorkSpace.Length - 1);
                }
                SvnRepo           = new SvnPort(name, Repository);
                SvnRepo.Workspace = WorkSpace;

                // 读取修改单配置明细
                log.WriteFileLog("读取开发工具信息");
                xn      = root.SelectSingleNode("Develop");
                DevTool = xn.Attributes["devtool"].InnerText;
                Rar     = xn.Attributes["rar"].InnerText;
                OutDir  = xn.Attributes["outdir"].InnerText;
                // OutDir 如果以 \ 结尾,会导致编译前台Drp时,批处理里会出现 "C:\src\", \"会被认为是转义,就报错了,
                // 这里如果,结尾是\,去掉
                if (OutDir[OutDir.Length - 1] == '\\')
                {
                    OutDir = OutDir.Substring(0, OutDir.Length - 1);
                }

                // 读取Ssh连接配置
                log.WriteFileLog("读取Ssh连接配置");
                xn   = root.SelectSingleNode("SSHConn");
                Conn = new ReSSH(xn.Attributes["name"].InnerText,
                                 xn.Attributes["host"].InnerText,
                                 int.Parse(xn.Attributes["port"].InnerText),
                                 xn.Attributes["user"].InnerText,
                                 xn.Attributes["pass"].InnerText,
                                 bool.Parse(xn.Attributes["restartas"].InnerText));
                Conn.localdir = OutDir;

                // 读取小球FTP路径递交配置
                log.WriteFileLog("读取小球FTP路径递交配置");
                xn           = root.SelectSingleNode("CommitFtp");
                fc           = new FtpConf();
                fc.host      = xn.Attributes["host"].InnerText;
                fc.port      = int.Parse(xn.Attributes["port"].InnerText);
                fc.user      = xn.Attributes["user"].InnerText;
                fc.pass      = xn.Attributes["pass"].InnerText;
                fc.ServerDir = xn.Attributes["remotedir"].Value;
                fc.LocalDir  = xn.Attributes["localdir"].Value;
                if (fc.LocalDir[fc.LocalDir.Length - 1] == '\\')
                {
                    fc.LocalDir = fc.LocalDir.Substring(0, fc.LocalDir.Length - 1);
                }

                // 初始化 ftp配置
                ftp = new FTPConnection();
                ftp.ServerAddress   = fc.host;
                ftp.ServerPort      = fc.port;
                ftp.UserName        = fc.user;
                ftp.Password        = fc.pass;
                ftp.TransferType    = FTPTransferType.BINARY;         // 指定 BINARY 传输,否则对于压缩包会失败
                ftp.CommandEncoding = Encoding.GetEncoding("gb2312"); // 重要,否则乱码且连接不

                log.WriteFileLog("读取对比参数");
                xn         = root.SelectSingleNode("Diff");
                DiffEnable = bool.Parse(xn.Attributes["enable"].Value);
                DiffBin    = xn.Attributes["bin"].Value;
                DiffArgs   = xn.Attributes["args"].Value;

                log.WriteFileLog("读取Delphi编译版本配置");
                xn      = root.SelectSingleNode("SpecialCom");
                SpeComs = new ArrayList();
                XmlNodeList xnl = xn.ChildNodes;
                foreach (XmlNode x in xnl)
                {
                    if (x.NodeType == XmlNodeType.Comment)
                    {
                        continue;
                    }
                    ComInfo com = new ComInfo(x.Attributes["lang"].Value,
                                              int.Parse(x.Attributes["ver"].Value),
                                              x.Attributes["coms"].Value);
                    SpeComs.Add(com);
                }

                // 读取数据库连接属性
                xn  = root.SelectSingleNode("DB");
                xnl = xn.ChildNodes;
                foreach (XmlNode x in xnl)
                {
                    DBUser u = new DBUser(x.Attributes["name"].InnerText,
                                          x.Attributes["pass"].InnerText,
                                          x.Attributes["dbtns"].InnerText,
                                          x.Attributes["note"].InnerText);
                    Users.Add(u);
                }


                // 读取公用递交配置
                try
                {
                    xn         = root.SelectSingleNode("CommitPublic");
                    logmessage = xn.Attributes["logmessage"].Value;
                    xnl        = xn.ChildNodes;
                    foreach (XmlNode x in xnl)
                    {
                        CommitPublic.Add(x.Attributes["dir"].InnerText);
                    }
                }
                catch
                {
                    log.WriteLog("无法读取公共递交资源CommitPublic!,请检查MAConf.xml配置");
                }
            }
            catch (Exception e)
            {
                log.WriteLog("加载配置失败,活动节点:" + xn.Name + e.Message, LogLevel.Error);
                throw new MissingFieldException("LoadConf");
            }
        }
Esempio n. 5
0
    public virtual async Task EndToEndTest()
    {
        await Git.EnsureNoPendingChanges();

        await Pack();

        var testDir = OutDir.Combine("EndToEndTest");
        await testDir.EnsureNotExists();

        testDir.EnsureDirectoryExists();

        var nugetConfigFile = testDir.Combine("nuget.config");

        await CreateNugetConfigFile(nugetConfigFile, PackagesDir);

        var nuget = new Tool("nuget.exe").WithWorkingDirectory(testDir);
        await nuget.Run("source");

        var script = testDir.Combine("build.cmd");
        await Root.Combine("examples", "skeleton").CopyTree(testDir);

        foreach (var d in new[] { "obj", "bin" })
        {
            await testDir.Combine("build", d).EnsureNotExists();
        }

        var version = await Git.GetVersion();

        var build = new Tool(script).DoNotCheckExitCode()
                    .WithEnvironment(new Dictionary <string, string> {
            { "AmgBuildVersion", version.NuGetVersion }
        })
        ;

        {
            var result = await build.Run();

            if (!result.ExitCode.Equals(0))
            {
                throw new Exception();
            }
            if (!result.Output.Contains(version.InformationalVersion))
            {
                throw new Exception();
            }
            if (!String.IsNullOrEmpty(result.Error))
            {
                throw new Exception(result.Error);
            }
        }

        {
            var result = await build.Run();

            if (!result.ExitCode.Equals(0))
            {
                throw new Exception();
            }
            if (!String.IsNullOrEmpty(result.Error))
            {
                throw new Exception(result.Error);
            }
        }

        {
            var result = await build.Run("--help");

            if (!result.ExitCode.Equals(3))
            {
                throw new Exception();
            }
        }

        {
            var result = await build.Run("--clean");

            if (!result.ExitCode.Equals(0))
            {
                throw new Exception();
            }
            if (!result.Output.Contains("Build script requires rebuild."))
            {
                throw new Exception();
            }
        }

        {
            var outdated = DateTime.UtcNow.AddDays(-1);
            foreach (var f in testDir.Combine("build", "bin").Glob("**/*").EnumerateFileInfos())
            {
                f.LastWriteTimeUtc = outdated;
            }

            var result = await build.Run();

            if (!result.ExitCode.Equals(0))
            {
                throw new Exception();
            }
            if (!result.Output.Contains("Build script requires rebuild."))
            {
                throw new Exception();
            }
        }
    }
Esempio n. 6
0
        void RunPackager()
        {
            string           options   = $"--copy=always --out=\"{managedPath.TrimEnd('\\')}\" --search-path=\"{OutDir.TrimEnd('\\')}\" {Assembly}";
            ProcessStartInfo startInfo = new ProcessStartInfo(Path.Combine(sdkPath, "packager.exe"), options);

            startInfo.UseShellExecute       = false;
            startInfo.RedirectStandardError = true;
            //startInfo.RedirectStandardInput = true;
            startInfo.RedirectStandardOutput = true;
            startInfo.StandardErrorEncoding  = System.Text.Encoding.UTF8;
            startInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;


            var process = new Process {
                StartInfo = startInfo
            };

            process.Start();

            string cv_error = null;
            Thread et       = new Thread(() => { cv_error = process.StandardError.ReadToEnd(); });

            et.Start();

            string cv_out = null;
            Thread ot     = new Thread(() => { cv_out = process.StandardOutput.ReadToEnd(); });

            ot.Start();

            process.WaitForExit();
            et.Join();
            string output = cv_error;// process.StandardError.ReadToEnd();

            ok = (process.ExitCode == 0);
            if (!ok)
            {
                Log.LogError(cv_error);
            }
            else
            {
                Log.LogMessage(cv_out);
            }

            process.Close();
        }
Esempio n. 7
0
        void RunPackager()
        {
            try
            {
                var enviromentPath = System.Environment.GetEnvironmentVariable("PATH");
                if (!isLinux())
                {
                    enviromentPath = enviromentPath + ";" + Environment.GetEnvironmentVariable("SystemRoot") + @"\sysnative";
                }
                string app = "dotnet";
                //Console.WriteLine(enviromentPath);
                var           paths   = enviromentPath.Split(isLinux() ? ':' : ';');
                List <string> pathEXT = new List <string>();
                if (!isLinux())
                {
                    pathEXT = System.Environment.GetEnvironmentVariable("PATHEXT").Split(';').ToList();
                }

                if ((app.IndexOf(".") > 0) || isLinux())
                {
                    pathEXT.Insert(0, "");
                }

                var dotnetPath = (from ext in pathEXT
                                  from path in paths
                                  where File.Exists(Path.Combine(path, app + ext))
                                  select Path.Combine(path, app + ext)).FirstOrDefault();

                string options = $"\"{Path.Combine(sdkPath,"packager.dll")}\" --copy=always --out=\"{managedPath.TrimEnd('\\')}\" --search-path=\"{OutDir.TrimEnd('\\')}\" {Assembly}";
                Log.LogMessage($"-----BuildWasm Running packager: {dotnetPath} {options} ------");
                ProcessStartInfo startInfo = new ProcessStartInfo(dotnetPath, options);
                startInfo.UseShellExecute       = false;
                startInfo.RedirectStandardError = true;
                //startInfo.RedirectStandardInput = true;
                startInfo.RedirectStandardOutput = true;
                startInfo.StandardErrorEncoding  = System.Text.Encoding.UTF8;
                startInfo.StandardOutputEncoding = System.Text.Encoding.UTF8;


                var process = new Process {
                    StartInfo = startInfo
                };
                process.Start();

                string cv_error = null;
                Thread et       = new Thread(() => { cv_error = process.StandardError.ReadToEnd(); });
                et.Start();

                string cv_out = null;
                Thread ot     = new Thread(() => { cv_out = process.StandardOutput.ReadToEnd(); });
                ot.Start();

                process.WaitForExit();
                et.Join();
                string output = cv_error;// process.StandardError.ReadToEnd();
                ok = (process.ExitCode == 0);
                if (!ok)
                {
                    Log.LogError(cv_error);
                }
                else
                {
                    Log.LogMessage(cv_out);
                }

                process.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error while executing packager." + ex.Message);
                Log.LogError("Error while executing packager." + ex.Message);
            }
        }