Ejemplo n.º 1
0
        public static BuildTargetResult ReplaceCoreHostPackaging(BuildTargetContext c)
        {
            ReplaceFileContents(@"pkg\dir.props", contents =>
            {
                DependencyInfo coreFXInfo = c.GetCoreFXDependency();
                Regex regex = new Regex(@"Microsoft\.NETCore\.Platforms\\(?<version>\d\.\d\.\d)-(?<release>.*)\\runtime\.json");

                return(regex.ReplaceGroupValue(contents, "release", coreFXInfo.NewReleaseVersion));
            });

            return(c.Success());
        }
Ejemplo n.º 2
0
        public static BuildTargetResult ReplaceCrossGen(BuildTargetContext c)
        {
            ReplaceFileContents(@"build_projects\dotnet-cli-build\CompileTargets.cs", compileTargetsContent =>
            {
                DependencyInfo coreFXInfo = c.GetCoreFXDependency();
                Regex regex = new Regex(@"CoreCLRVersion = ""(?<version>\d.\d.\d)-(?<release>.*)"";");

                return(regex.ReplaceGroupValue(compileTargetsContent, "release", coreFXInfo.NewReleaseVersion));
            });

            return(c.Success());
        }
Ejemplo n.º 3
0
        public static BuildTargetResult ReplaceCrossGen(BuildTargetContext c)
        {
            ReplaceFileContents(@"build_projects\shared-build-targets-utils\DependencyVersions.cs", dependencyVersionsContent =>
            {
                DependencyInfo coreFXInfo = c.GetCoreFXDependency();
                Regex regex = new Regex(@"CoreCLRVersion = ""(?<version>\d.\d.\d)-(?<release>.*)"";");

                // TODO: this needs a CoreCLR DependencyInfo
                return(regex.ReplaceGroupValue(dependencyVersionsContent, "release", coreFXInfo.NewReleaseVersion));
            });

            return(c.Success());
        }
Ejemplo n.º 4
0
        public static BuildTargetResult ReplaceDependencyVersions(BuildTargetContext c)
        {
            ReplaceFileContents(@"build_projects\shared-build-targets-utils\DependencyVersions.cs", fileContents =>
            {
                DependencyInfo coreFXInfo    = c.GetCoreFXDependency();
                DependencyInfo coreSetupInfo = c.GetCoreSetupDependency();

                fileContents = ReplaceDependencyVersion(fileContents, coreFXInfo, "CoreCLRVersion", "Microsoft.NETCore.Runtime.CoreCLR");
                fileContents = ReplaceDependencyVersion(fileContents, coreSetupInfo, "SharedFrameworkVersion", "Microsoft.NETCore.App");
                fileContents = ReplaceDependencyVersion(fileContents, coreSetupInfo, "SharedHostVersion", "Microsoft.NETCore.DotNetHost");

                return(fileContents);
            });

            return(c.Success());
        }
Ejemplo n.º 5
0
        private static string ReplaceDependencyVersion(string fileContents, DependencyInfo dependencyInfo, string dependencyPropertyName, string packageId)
        {
            Regex regex = new Regex($@"{dependencyPropertyName} = ""(?<version>.*)"";");

            string newVersion = dependencyInfo
                                .NewVersions
                                .FirstOrDefault(p => p.Id == packageId)
                                ?.Version
                                .ToNormalizedString();

            if (string.IsNullOrEmpty(newVersion))
            {
                throw new InvalidOperationException($"Could not find package version information for '{packageId}'");
            }

            return(regex.ReplaceGroupValue(fileContents, "version", newVersion));
        }
Ejemplo n.º 6
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());
        }