Ejemplo n.º 1
0
        public static BuildTargetResult GetDependencies(BuildTargetContext c)
        {
            string coreFxLkgVersion = s_client.GetStringAsync(Config.Instance.CoreFxVersionUrl).Result;

            coreFxLkgVersion = coreFxLkgVersion.Trim();

            const string coreFxIdPattern          = @"^(?i)((System\..*)|(NETStandard\.Library)|(Microsoft\.CSharp)|(Microsoft\.NETCore.*)|(Microsoft\.TargetingPack\.Private\.(CoreCLR|NETNative))|(Microsoft\.Win32\..*)|(Microsoft\.VisualBasic))$";
            const string coreFxIdExclusionPattern = @"System.CommandLine";

            List <DependencyInfo> dependencyInfos = c.GetDependencyInfo();

            dependencyInfos.Add(new DependencyInfo()
            {
                Name               = "CoreFx",
                IdPattern          = coreFxIdPattern,
                IdExclusionPattern = coreFxIdExclusionPattern,
                NewReleaseVersion  = coreFxLkgVersion
            });

            return(c.Success());
        }
Ejemplo n.º 2
0
        public static BuildTargetResult ReplaceProjectJson(BuildTargetContext c)
        {
            List <DependencyInfo> dependencyInfos = c.GetDependencyInfo();

            IEnumerable <string> projectJsonFiles = Enumerable.Union(
                Directory.GetFiles(Dirs.RepoRoot, "project.json", SearchOption.AllDirectories),
                Directory.GetFiles(Path.Combine(Dirs.RepoRoot, @"src\dotnet\commands\dotnet-new"), "project.json.template", SearchOption.AllDirectories));

            JObject projectRoot;

            foreach (string projectJsonFile in projectJsonFiles)
            {
                try
                {
                    projectRoot = ReadProject(projectJsonFile);
                }
                catch (Exception e)
                {
                    c.Warn($"Non-fatal exception occurred reading '{projectJsonFile}'. Skipping file. Exception: {e}. ");
                    continue;
                }

                bool changedAnyPackage = FindAllDependencyProperties(projectRoot)
                                         .Select(dependencyProperty => ReplaceDependencyVersion(dependencyProperty, dependencyInfos))
                                         .ToArray()
                                         .Any(shouldWrite => shouldWrite);

                if (changedAnyPackage)
                {
                    c.Info($"Writing changes to {projectJsonFile}");
                    WriteProject(projectRoot, projectJsonFile);
                }
            }

            return(c.Success());
        }
Ejemplo n.º 3
0
        public static BuildTargetResult ReplaceCrossGen(BuildTargetContext c)
        {
            DependencyInfo coreFXInfo = c.GetDependencyInfo().Single(d => d.Name == "CoreFx");

            string compileTargetsPath    = Path.Combine(Dirs.RepoRoot, @"scripts\dotnet-cli-build\CompileTargets.cs");
            string compileTargetsContent = File.ReadAllText(compileTargetsPath);

            Regex regex = new Regex(@"CoreCLRVersion = ""(?<version>\d.\d.\d)-(?<release>.*)"";");

            compileTargetsContent = regex.Replace(compileTargetsContent, m =>
            {
                string replacedValue = m.Value;
                Group releaseGroup   = m.Groups["release"];

                replacedValue = replacedValue.Remove(releaseGroup.Index - m.Index, releaseGroup.Length);
                replacedValue = replacedValue.Insert(releaseGroup.Index - m.Index, coreFXInfo.NewReleaseVersion);

                return(replacedValue);
            });

            File.WriteAllText(compileTargetsPath, compileTargetsContent, Encoding.UTF8);

            return(c.Success());
        }