File tree Expand file tree Collapse file tree 1 file changed +23
-2
lines changed
src/Microsoft.Extensions.Configuration.AzureAppConfiguration Expand file tree Collapse file tree 1 file changed +23
-2
lines changed Original file line number Diff line number Diff line change 55using System . Collections . Generic ;
66using System . Diagnostics ;
77using System . Linq ;
8+ using System . Reflection ;
89using System . Security ;
910using System . Text ;
1011using System . Threading . Tasks ;
@@ -79,8 +80,28 @@ public static string GetAssemblyVersion(string assemblyName)
7980 {
8081 if ( ! string . IsNullOrEmpty ( assemblyName ) )
8182 {
82- // Return the version using only the first 3 fields and remove additional characters
83- return AppDomain . CurrentDomain . GetAssemblies ( ) . SingleOrDefault ( assembly => assembly . GetName ( ) . Name == assemblyName ) ? . GetName ( ) . Version ? . ToString ( 3 ) . Trim ( '{' , '}' ) ;
83+ Assembly infoVersionAttribute = AppDomain . CurrentDomain . GetAssemblies ( ) . SingleOrDefault ( assembly => assembly . GetName ( ) . Name == assemblyName ) ;
84+
85+ if ( infoVersionAttribute != null )
86+ {
87+ string informationalVersion = infoVersionAttribute . GetCustomAttribute < AssemblyInformationalVersionAttribute > ( ) ? . InformationalVersion ;
88+
89+ if ( string . IsNullOrEmpty ( informationalVersion ) )
90+ {
91+ return null ;
92+ }
93+
94+ // Commit information is appended to the informational version starting with a '+', so we remove
95+ // the commit information to get just the full name of the version.
96+ int plusIndex = informationalVersion . IndexOf ( '+' ) ;
97+
98+ if ( plusIndex != - 1 )
99+ {
100+ informationalVersion = informationalVersion . Substring ( 0 , plusIndex ) ;
101+ }
102+
103+ return informationalVersion ;
104+ }
84105 }
85106
86107 return null ;
You can’t perform that action at this time.
0 commit comments