Exemple #1
0
        public static void SetVersion(string filePath, Version newVersion, bool writeToDisk)
        {
            var file = ReadFile(filePath);
            var contents = file.Key;
            var encoding = file.Value;

            Logger.InfoFormat("File \"{0}\" has encoding {1}", filePath, encoding.EncodingName);

            contents = AssemblyRegex.Replace(contents, "${1}" + newVersion + "${3}");
            contents = InstallBuilderVersionRegex.Replace(contents, "${1}" + newVersion + "${3}");
            contents = InstallBuilderVersionIdRegex.Replace(contents, "${1}" + newVersion.GetId() + "${3}");
            contents = InstallBuilderUpdateVersionIdRegex.Replace(contents, "${1}" + newVersion.GetId() + "${3}");
            contents = InnoSetupVersionRegex.Replace(contents, "${1}" + newVersion + "${3}");
            contents = ArtifactFileNameRegex.Replace(contents, "${1}" + newVersion + "${3}");

            if (writeToDisk)
            {
                File.WriteAllText(filePath, contents, encoding);
            }
        }