예제 #1
0
파일: Packages.cs 프로젝트: Eye-Soft/HSDK
        public static Package Parse(FileInfo assemblyInfoFile)
        {
            try
            {
                var lines = Storage.ReadAllLines(assemblyInfoFile.FullName);

                var title = AssemblyInfo.GetData(lines, AssemblyInfoData.AssemblyTitle);

                var projectFile = assemblyInfoFile.Directory.Parent.GetFiles(title + "*.csproj").SingleOrDefault();

                if (projectFile == null)
                {
                    return(null);
                }

                var targetFramework = ExtractTargetFramework(projectFile);

                var version = AssemblyInfo.GetData(lines, AssemblyInfoData.AssemblyVersion);

                var nuspec = projectFile.Directory.GetFiles("Package.nuspec").SingleOrDefault();

                if (nuspec == null)
                {
                    return(new Package(projectFile, assemblyInfoFile, lines, title, version, targetFramework));
                }

                return(new Package(projectFile, assemblyInfoFile, lines, title, version, targetFramework, nuspec));
            }
            catch (Exception exception)
            {
                throw new IOException($"Cannot parse the file {assemblyInfoFile.FullName}.", exception);
            }
        }
예제 #2
0
        private static void UpdateAssemblyVersionLine(
            Version newVersion,
            IReadOnlyList <AssemblyInfoLine> assemblyInfoLines,
            AssemblyInfoData assemblyInfo)
        {
            var assemblyInfoVersion = assemblyInfo.ToString();

            var assemblyVersion = assemblyInfoLines.Single(x => x.Line.Contains(assemblyInfoVersion));

            var assemblyVersionLine = assemblyVersion.Line;

            var version = AssemblyInfo.GetData(assemblyVersion.Line, assemblyInfo);

            assemblyInfoLines[assemblyVersion.Index].Line = assemblyVersionLine.Replace(version, newVersion.ToString());
        }