diff --git a/product/roundhouse/infrastructure.app/builders/VersionResolverBuilder.cs b/product/roundhouse/infrastructure.app/builders/VersionResolverBuilder.cs index 229a1736..2be35e78 100644 --- a/product/roundhouse/infrastructure.app/builders/VersionResolverBuilder.cs +++ b/product/roundhouse/infrastructure.app/builders/VersionResolverBuilder.cs @@ -10,9 +10,10 @@ public static VersionResolver build(FileSystemAccess file_system, ConfigurationP { VersionResolver xml_version_finder = new XmlFileVersionResolver(file_system, configuration_property_holder.VersionXPath, configuration_property_holder.VersionFile); VersionResolver dll_version_finder = new DllFileVersionResolver(file_system, configuration_property_holder.VersionFile); + VersionResolver text_version_finder = new TextVersionResolver(file_system, configuration_property_holder.VersionFile); VersionResolver script_number_version_finder = new ScriptfileVersionResolver(file_system, configuration_property_holder); - - IEnumerable resolvers = new List { xml_version_finder, dll_version_finder, script_number_version_finder }; + + IEnumerable resolvers = new List { xml_version_finder, dll_version_finder, text_version_finder, script_number_version_finder }; return new ComplexVersionResolver(resolvers); } diff --git a/product/roundhouse/resolvers/TextVersionResolver.cs b/product/roundhouse/resolvers/TextVersionResolver.cs new file mode 100644 index 00000000..9810d1c9 --- /dev/null +++ b/product/roundhouse/resolvers/TextVersionResolver.cs @@ -0,0 +1,52 @@ +using System; + +using roundhouse.infrastructure.filesystem; +using roundhouse.infrastructure.logging; + +namespace roundhouse.resolvers +{ + public class TextVersionResolver : VersionResolver + { + private readonly FileSystemAccess file_system; + private readonly string version_file; + + public TextVersionResolver(FileSystemAccess file_system, string version_file) + { + this.file_system = file_system; + this.version_file = version_file; + } + + public bool meets_criteria() + { + return version_file.EndsWith(".txt", StringComparison.OrdinalIgnoreCase); + } + + public string resolve_version() + { + Log.bound_to(this).log_an_info_event_containing( + " Attempting to resolve version from text file {0}.", version_file); + + string version = "0"; + if (file_system.file_exists(version_file)) + { + try + { + version = file_system.read_file_text(version_file); + Log.bound_to(this).log_an_info_event_containing(" Found version {0} from {1}.", version, version_file); + } + catch (Exception e) + { + Log.bound_to(this).log_an_error_event_containing( + "Unable to get version from text file {0}:{1}{2}", version_file, Environment.NewLine, e.Message); + } + } + else + { + Log.bound_to(this).log_a_warning_event_containing( + "Unable to get version from text file {0}. File doesn't exist.", version_file); + } + + return version; + } + } +} \ No newline at end of file diff --git a/product/roundhouse/roundhouse.csproj b/product/roundhouse/roundhouse.csproj index abb8a365..56b0f5e0 100644 --- a/product/roundhouse/roundhouse.csproj +++ b/product/roundhouse/roundhouse.csproj @@ -132,6 +132,7 @@ +