예제 #1
0
        private static void BuildProject(ProjectSetting project)
        {
            BuildContext buildContext = null;

            ICodeBuild build = null;

            if (project.Solution != null)
            {
                buildContext = CreateBuildContext(project);
                build        = ACodeBuild.CreateBuild(buildContext);
                LogType.WriteLog(project.ProjectName, "生成解决方案", string.Format("开始生成解决方案:{0}", buildContext.BuildPath));
                try
                {
                    build.Build(buildContext);
                }
                catch (Exception ee)
                {
                    LogType.WriteLog(project.ProjectName, "生成解决方案", string.Format("生成错误:{0}", ee.Message));
                }

                LogType.WriteLog(project.ProjectName, "生成解决方案", string.Format("解决方案生成完成:{0}", buildContext.Log));
            }
        }
예제 #2
0
        private static void PubilshWeb(ProjectSetting project)
        {
            if (project.Publish != null && project.Publish.TargetDirectorys.Count > 0)
            {
                var buildContext = CreateBuildContext(project);
                var build        = ACodeBuild.CreateBuild(buildContext);

                var target = project.Publish.TargetDirectorys.FirstOrDefault().Path;
                buildContext.publishDirectory = target + "_temp_" + project.ProjectName;;
                buildContext.PublishItemPath  = project.Publish.Path;
                LogType.WriteLog(project.ProjectName, "发布网站项目", string.Format("开始发布网站项目:{0}", project.Publish.Path));
                if (!Directory.Exists(buildContext.publishDirectory))
                {
                    Directory.CreateDirectory(buildContext.publishDirectory);
                }
                LogType.WriteLog(project.ProjectName, "发布网站项目", string.Format("发布地址:{0}", buildContext.publishDirectory));
                try
                {
                    build.Publish(buildContext);
                }
                catch (Exception ee)
                {
                    LogType.WriteLog(project.ProjectName, "发布网站项目", string.Format("网站发布错误:{0}", ee.Message));
                }
                LogType.WriteLog(project.ProjectName, "发布网站项目", string.Format("网站项目发布完成:{0}:", buildContext.Log));
                var log = buildContext.Log;
                if (log.IndexOf("0 个错误") < 0)
                {
                    var status = GetStatus(project.ProjectName);
                    status.Status = ProjectStatusEnum.Error;
                }
                MoveToLose(project);/*生成后再移动忽略文件*/
                //拷贝发布成功的文件
                CopyPublish(project, buildContext);
                MoveToLose(project, false);
            }
        }
예제 #3
0
        public void PublishTest()
        {
            var context = BuildContext.CreateBuildContext(
                BuildTypeEnum.MSBuild,
                buildPath: @"C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe",
                codePath: @"D:\KongHao\KongHao\Code\git\AlosTRM\AlosNew.sln",
                publishItemPath: @"D:\KongHao\KongHao\Code\git\AlosTRM\WebServer\WebServer.csproj",
                publishDirectory: @"D:\TESTsvn\BBT"
                );
            var build = ACodeBuild.CreateBuild(context);

            build.Publish(context);
            var log = context.Log;

            if (log.IndexOf("0 个错误") > -1)
            {
                Debug.WriteLine(log);
            }
            else
            {
                Debug.WriteLine(log);
                Assert.Fail();
            }
        }