diff --git a/CKAN/CKAN/CKAN.csproj b/CKAN/CKAN/CKAN.csproj index 867c8ca969..c6a7348da9 100644 --- a/CKAN/CKAN/CKAN.csproj +++ b/CKAN/CKAN/CKAN.csproj @@ -62,6 +62,7 @@ + diff --git a/CKAN/CKAN/Meta.cs b/CKAN/CKAN/Meta.cs new file mode 100644 index 0000000000..e7d9bfc981 --- /dev/null +++ b/CKAN/CKAN/Meta.cs @@ -0,0 +1,27 @@ +namespace CKAN { + using System; + using System.Reflection; + + public static class Meta { + /// + /// Returns the version of the CKAN.dll used. + /// + + public static string Version() { + + var assembly = Assembly.GetExecutingAssembly(); + + // SeriouslyLongestClassNamesEverThanksMicrosoft + var attr = (AssemblyInformationalVersionAttribute[]) assembly.GetCustomAttributes (typeof(AssemblyInformationalVersionAttribute), false); + + if (attr.Length == 0 || attr [0].InformationalVersion == null) { + // Dunno the version. Some dev probably built it. + return "development"; + } else { + return attr[0].InformationalVersion; + } + + } + } +} + diff --git a/CKAN/CmdLine/Main.cs b/CKAN/CmdLine/Main.cs index ef5bbb3fc7..1a3f20c7a4 100644 --- a/CKAN/CmdLine/Main.cs +++ b/CKAN/CmdLine/Main.cs @@ -131,15 +131,7 @@ static int Gui() { static int Version() { - // SeriouslyLongestClassNamesEverThanksMicrosoft - var assemblies = (AssemblyInformationalVersionAttribute[]) Assembly.GetAssembly (typeof(MainClass)).GetCustomAttributes (typeof(AssemblyInformationalVersionAttribute), false); - - if (assemblies.Length == 0 || assemblies[0].InformationalVersion == null) { - // Dunno the version. Some dev probably built it. - User.WriteLine ("development"); - } else { - User.WriteLine (assemblies[0].InformationalVersion); - } + User.WriteLine (Meta.Version ()); return EXIT_OK; } diff --git a/CKAN/GUI/Main.cs b/CKAN/GUI/Main.cs index 4d9f7cbdda..0434178fd5 100644 --- a/CKAN/GUI/Main.cs +++ b/CKAN/GUI/Main.cs @@ -67,17 +67,8 @@ private void Main_Load(object sender, EventArgs e) ApplyToolButton.Enabled = false; - var assemblies = (AssemblyInformationalVersionAttribute[])Assembly.GetAssembly(typeof(RegistryManager)).GetCustomAttributes(typeof(AssemblyInformationalVersionAttribute), false); + Text = "CKAN (" + Meta.Version() + ")"; - if (assemblies.Length == 0 || assemblies[0].InformationalVersion == null) - { - // Dunno the version. Some dev probably built it. - Text = "CKAN (development)"; - } - else - { - Text = String.Format("CKAN {0}", assemblies[0].InformationalVersion); - } } private static Main m_Instance = null; diff --git a/bin/build b/bin/build index c8c7f431a3..6c2ec7241c 100755 --- a/bin/build +++ b/bin/build @@ -1153,7 +1153,11 @@ my $BUILD = "$Bin/../build"; my $SOURCE = "$Bin/../CKAN"; my @CP = qw(cp -r --reflink=auto --sparse=always); my $VERSION = capturex(qw(git describe --long)); -my $ASSEMBLY_INFO = File::Spec->catdir($BUILD,"CKAN/Properties/AssemblyInfo.cs"); +my @ASSEMBLY_INFO = ( + File::Spec->catdir($BUILD,"CKAN/Properties/AssemblyInfo.cs"), + File::Spec->catdir($BUILD,"CmdLine/Properties/AssemblyInfo.cs"), + File::Spec->catdir($BUILD,"GUI/Properties/AssemblyInfo.cs"), +); # Remove newline chomp($VERSION); @@ -1169,9 +1173,12 @@ remove_tree(File::Spec->catdir($BUILD, "CKAN/bin")); remove_tree(File::Spec->catdir($BUILD, "CKAN/obj")); # Before we build, add our version number in. -open(my $assembly_fh, ">>", $ASSEMBLY_INFO); -say {$assembly_fh} qq{[assembly: AssemblyInformationalVersion ("$VERSION")]}; -close($assembly_fh); + +foreach my $assembly (@ASSEMBLY_INFO) { + open(my $assembly_fh, ">>", $assembly); + say {$assembly_fh} qq{[assembly: AssemblyInformationalVersion ("$VERSION")]}; + close($assembly_fh); +} # Change to our build directory chdir($BUILD); diff --git a/bin/build.lean b/bin/build.lean index 13e9624da7..8843cbddff 100755 --- a/bin/build.lean +++ b/bin/build.lean @@ -17,7 +17,11 @@ my $BUILD = "$Bin/../build"; my $SOURCE = "$Bin/../CKAN"; my @CP = qw(cp -r --reflink=auto --sparse=always); my $VERSION = capturex(qw(git describe --long)); -my $ASSEMBLY_INFO = File::Spec->catdir($BUILD,"CKAN/Properties/AssemblyInfo.cs"); +my @ASSEMBLY_INFO = ( + File::Spec->catdir($BUILD,"CKAN/Properties/AssemblyInfo.cs"), + File::Spec->catdir($BUILD,"CmdLine/Properties/AssemblyInfo.cs"), + File::Spec->catdir($BUILD,"GUI/Properties/AssemblyInfo.cs"), +); # Remove newline chomp($VERSION); @@ -33,9 +37,12 @@ remove_tree(File::Spec->catdir($BUILD, "CKAN/bin")); remove_tree(File::Spec->catdir($BUILD, "CKAN/obj")); # Before we build, add our version number in. -open(my $assembly_fh, ">>", $ASSEMBLY_INFO); -say {$assembly_fh} qq{[assembly: AssemblyInformationalVersion ("$VERSION")]}; -close($assembly_fh); + +foreach my $assembly (@ASSEMBLY_INFO) { + open(my $assembly_fh, ">>", $assembly); + say {$assembly_fh} qq{[assembly: AssemblyInformationalVersion ("$VERSION")]}; + close($assembly_fh); +} # Change to our build directory chdir($BUILD);