コード例 #1
0
        public void NugetRestore(string moduleName, List <string> configurations, string nugetRunCommand)
        {
            if (Yaml.Exists(moduleName))
            {
                var buildSections = configurations.SelectMany(c => Yaml.BuildParser(moduleName).Get(c)).ToList();
                var targets       = new HashSet <string>();
                foreach (var buildSection in buildSections)
                {
                    if (buildSection.Target == null || !buildSection.Target.EndsWith(".sln"))
                    {
                        continue;
                    }
                    if (buildSection.Tool.Name != "dotnet")
                    {
                        var target = Path.Combine(Helper.CurrentWorkspace, moduleName, buildSection.Target);
                        targets.Add(target);
                    }
                }

                foreach (var target in targets)
                {
                    RunNugetRestore(target, nugetRunCommand);
                }
            }
            else
            {
                RunNugetRestore(Path.Combine(Helper.CurrentWorkspace, moduleName, "build.cmd"), nugetRunCommand);
            }
        }
コード例 #2
0
ファイル: TestConvertSpec.cs プロジェクト: skbkontur/cement
        public void TestGetBuildSection()
        {
            AddBuildScript("kanso.sln", null);
            new ConvertSpecCommand().Run(new[] { "convert-spec" });

            var data = Yaml.BuildParser("module").Get();

            Assert.That(data.Count == 1);
            Assert.That(data[0].Configuration == "Release");
            Assert.That(data[0].Target == "kanso.sln");
        }
コード例 #3
0
ファイル: RefFix.cs プロジェクト: vd-borovikov/cement
        private void Fix()
        {
            oldYamlContent = Yaml.ReadAllText(rootModuleName);

            var modules = Helper.GetModules();

            var configs        = Yaml.ConfigurationParser(rootModuleName).GetConfigurations();
            var buildsInfo     = configs.SelectMany(config => Yaml.BuildParser(rootModuleName).Get(config));
            var processedFiles = new HashSet <string>();

            foreach (var buildInfo in buildsInfo)
            {
                Fix(buildInfo, modules, processedFiles);
            }
        }
コード例 #4
0
        protected override int Execute()
        {
            var modulePath = Helper.GetModuleDirectory(Directory.GetCurrentDirectory());
            var moduleName = Path.GetFileName(modulePath);

            project       = Yaml.GetProjectFileName(project, moduleName);
            configuration = configuration ?? "full-build";

            var buildData = Yaml.BuildParser(moduleName).Get(configuration).FirstOrDefault(t => !t.Target.IsFakeTarget());

            var projectPath = Path.GetFullPath(project);
            var csproj      = new ProjectFile(projectPath);
            var deps        = new DepsParser(modulePath).Get(configuration);

            ConsoleWriter.WriteInfo("patching csproj");
            var patchedDocument = csproj.CreateCsProjWithNugetReferences(deps.Deps, preRelease);
            var backupFileName  = Path.Combine(Path.GetDirectoryName(projectPath) ?? "", "backup." + Path.GetFileName(projectPath));

            if (File.Exists(backupFileName))
            {
                File.Delete(backupFileName);
            }
            File.Move(projectPath, backupFileName);
            try
            {
                XmlDocumentHelper.Save(patchedDocument, projectPath, "\n");
                var shellRunner   = new ShellRunner(LogManager.GetLogger <ShellRunner>());
                var cleaner       = new Cleaner(shellRunner);
                var moduleBuilder = new ModuleBuilder(Log, buildSettings);
                moduleBuilder.Init();
                ConsoleWriter.WriteInfo("start pack");
                if (!moduleBuilder.DotnetPack(modulePath, projectPath, buildData?.Configuration ?? "Release"))
                {
                    return(-1);
                }
            }
            finally
            {
                if (File.Exists(projectPath))
                {
                    File.Delete(projectPath);
                }
                File.Move(backupFileName, projectPath);
            }
            return(0);
        }
コード例 #5
0
 public void NugetRestore(Dep dep)
 {
     if (Yaml.Exists(dep.Name))
     {
         var buildSections = Yaml.BuildParser(dep.Name).Get(dep.Configuration);
         foreach (var buildSection in buildSections)
         {
             if (buildSection.Target == null || !buildSection.Target.EndsWith(".sln"))
             {
                 continue;
             }
             var target = Path.Combine(Helper.CurrentWorkspace, dep.Name, buildSection.Target);
             RunNugetRestore(target);
         }
     }
     else
     {
         RunNugetRestore(Path.Combine(Helper.CurrentWorkspace, dep.Name, "build.cmd"));
     }
 }
コード例 #6
0
        public static List <BuildScriptWithBuildData> PrepareBuildScriptsFromYaml(Dep dep)
        {
            var buildSections = Yaml.BuildParser(dep.Name).Get(dep.Configuration);

            var result = new List <BuildScriptWithBuildData>();

            foreach (var buildSection in buildSections)
            {
                if (buildSection.Target.IsFakeTarget())
                {
                    result.Add(null);
                }
                else
                {
                    var script = MakeScript(dep, buildSection);
                    result.Add(new BuildScriptWithBuildData(
                                   script,
                                   buildSection));
                }
            }
            return(result);
        }
コード例 #7
0
ファイル: Cleaner.cs プロジェクト: aidmsu/cement
        public bool IsNetStandard(Dep dep)
        {
            try
            {
                var modulePath    = Path.Combine(Helper.CurrentWorkspace, dep.Name);
                var buildSections = Yaml.BuildParser(dep.Name).Get(dep.Configuration);
                foreach (var buildSection in buildSections)
                {
                    if (buildSection.Target.IsFakeTarget() || !buildSection.Target.EndsWith(".sln"))
                    {
                        continue;
                    }

                    var slnPath = Path.Combine(modulePath, buildSection.Target);
                    using (var sln = new Sln(slnPath, SlnItems.Projects))
                    {
                        foreach (var projectItem in sln.Result.ProjectItems)
                        {
                            var csprojPath = projectItem.fullPath;
                            if (IsProjectsTargetFrameworkIsNetStandard(csprojPath))
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                ConsoleWriter.WriteInfo($"Could not check TargetFramework in '{dep.Name}'. Continue building without clean");
                log.LogWarning(e, $"An error occured when checking target framework in '{dep.Name}'");
                return(false);
            }

            return(false);
        }
コード例 #8
0
        public static List <BuildScriptWithBuildData> PrepareBuildScriptsFromYaml(Dep dep)
        {
            var buildSections = Yaml.BuildParser(dep.Name).Get(dep.Configuration);

            var result = new List <BuildScriptWithBuildData>();

            foreach (var buildSection in buildSections)
            {
                if (buildSection.Target == null || buildSection.Target.Equals("None"))
                {
                    result.Add(null);
                }
                else
                {
                    var script       = buildSection.Tool.Name == "msbuild" ? BuildMsbuildScript(buildSection, dep.Name) : BuildShellScript(buildSection);
                    var scriptIfFail = buildSection.Tool.Name == "msbuild" ? BuildMsbuildScript(buildSection, dep.Name) : BuildShellScript(buildSection);
                    result.Add(new BuildScriptWithBuildData(
                                   script,
                                   scriptIfFail,
                                   buildSection));
                }
            }
            return(result);
        }
コード例 #9
0
ファイル: DepsChecker.cs プロジェクト: madetara/cement
 private static bool IsContentModuel(Dep dep)
 {
     return(Yaml.SettingsParser(dep.Name).Get().IsContentModule || Yaml.BuildParser(dep.Name).Get(dep.Configuration)
            .All(t => t.Target == "None"));
 }