File tree Expand file tree Collapse file tree 13 files changed +428
-7
lines changed
VersionAssemblyInfoResources Expand file tree Collapse file tree 13 files changed +428
-7
lines changed Original file line number Diff line number Diff line change
1
+ namespace GitVersionCore . Extensions
2
+ {
3
+ using System . IO ;
4
+
5
+ public static class ReadEmbeddedResourceExtensions
6
+ {
7
+ /// <summary>
8
+ ///
9
+ /// </summary>
10
+ /// <typeparam name="T"></typeparam>
11
+ /// <param name="resourceName">Should include Namespace separated path to resource in assembly referenced by <typeparamref name="T"/></param>
12
+ /// <returns></returns>
13
+ public static string ReadAsStringFromEmbeddedResource < T > ( this string resourceName )
14
+ {
15
+ using ( var stream = resourceName . ReadFromEmbeddedResource < T > ( ) )
16
+ {
17
+ using ( var rdr = new StreamReader ( stream ) )
18
+ {
19
+ return rdr . ReadToEnd ( ) ;
20
+ }
21
+ }
22
+ }
23
+
24
+ public static Stream ReadFromEmbeddedResource < T > ( this string resourceName )
25
+ {
26
+ var assembly = typeof ( T ) . Assembly ;
27
+ return assembly . GetManifestResourceStream ( resourceName ) ;
28
+ }
29
+ }
30
+ }
Original file line number Diff line number Diff line change 109
109
<Compile Include =" Configuration\Init\StepResult.cs" />
110
110
<Compile Include =" EffectiveConfiguration.cs" />
111
111
<Compile Include =" ExecuteCore.cs" />
112
+ <Compile Include =" Extensions\ReadEmbeddedResourceExtensions.cs" />
112
113
<Compile Include =" GitPreparer.cs" />
113
114
<Compile Include =" GitVersionCache.cs" />
114
115
<Compile Include =" Helpers\FileSystem.cs" />
121
122
<Compile Include =" SemanticVersionExtensions.cs" />
122
123
<Compile Include =" SemanticVersionFormatValues.cs" />
123
124
<Compile Include =" StringFormatWith.cs" />
125
+ <Compile Include =" VersionAssemblyInfoResources\AssemblyVersionInfoTemplates.cs" />
126
+ <EmbeddedResource Include =" VersionAssemblyInfoResources\VersionAssemblyInfo.cs" />
124
127
<Compile Include =" VersionCalculation\BaseVersionCalculator.cs" />
125
128
<Compile Include =" VersionCalculation\BaseVersionCalculators\BaseVersion.cs" />
126
129
<Compile Include =" VersionCalculation\BaseVersionCalculators\ConfigNextVersionBaseVersionStrategy.cs" />
161
164
<Content Include =" FodyWeavers.xml" >
162
165
<SubType >Designer</SubType >
163
166
</Content >
167
+ <EmbeddedResource Include =" VersionAssemblyInfoResources\VersionAssemblyInfo.vb" />
168
+ <EmbeddedResource Include =" VersionAssemblyInfoResources\VersionAssemblyInfo.fs" />
164
169
</ItemGroup >
165
170
<ItemGroup >
166
171
<None Include =" NugetAssets\GitVersion.nuspec" >
Original file line number Diff line number Diff line change
1
+ namespace GitVersion . VersionAssemblyInfoResources
2
+ {
3
+ using System . Collections . Generic ;
4
+ using System . IO ;
5
+ using System . Linq ;
6
+ using GitVersionCore . Extensions ;
7
+
8
+ public class AssemblyVersionInfoTemplates
9
+ {
10
+ static IDictionary < string , FileInfo > assemblyInfoSourceList ;
11
+
12
+ static AssemblyVersionInfoTemplates ( )
13
+ {
14
+ var enclosingNamespace = typeof ( AssemblyVersionInfoTemplates ) . Namespace ;
15
+
16
+ var files = typeof ( AssemblyVersionInfoTemplates )
17
+ . Assembly
18
+ . GetManifestResourceNames ( )
19
+ . Where ( n => n . StartsWith ( enclosingNamespace ?? string . Empty ) ) . Select ( f => new FileInfo ( f ) ) ;
20
+
21
+ assemblyInfoSourceList = files . ToDictionary ( k => k . Extension , v => v ) ;
22
+ }
23
+
24
+ public static string GetAssemblyInfoTemplateFor ( string assemblyInfoFile )
25
+ {
26
+ var fi = new FileInfo ( assemblyInfoFile ) ;
27
+ if ( assemblyInfoSourceList . ContainsKey ( fi . Extension ) )
28
+ {
29
+ var template = assemblyInfoSourceList [ fi . Extension ] ;
30
+ if ( template != null )
31
+ {
32
+ return template . Name . ReadAsStringFromEmbeddedResource < AssemblyVersionInfoTemplates > ( ) ;
33
+ }
34
+ }
35
+ return null ;
36
+ }
37
+ }
38
+ }
Original file line number Diff line number Diff line change
1
+ //------------------------------------------------------------------------------
2
+ // <auto-generated>
3
+ // This code was generated by GitVersion.
4
+ //
5
+ // You can modify this code as we will not overwrite it when re-executing GitVersion
6
+ // </auto-generated>
7
+ //------------------------------------------------------------------------------
8
+
9
+ using System . Reflection ;
10
+
11
+ [ assembly: AssemblyFileVersion ( "0.0.0.0" ) ]
12
+ [ assembly: AssemblyVersion ( "0.0.0.0" ) ]
13
+ [ assembly: AssemblyInformationalVersion ( "0.0.0.0" ) ]
Original file line number Diff line number Diff line change
1
+ //------------------------------------------------------------------------------
2
+ // <auto-generated>
3
+ // This code was generated by GitVersion.
4
+ //
5
+ // You can modify this code as we will not overwrite it when re-executing GitVersion
6
+ // </auto-generated>
7
+ //------------------------------------------------------------------------------
8
+
9
+ open System.Reflection
10
+
11
+ [<assembly: AssemblyFileVersion( " 0.0.0.0" ) >]
12
+ [<assembly: AssemblyVersion( " 0.0.0.0" ) >]
13
+ [<assembly: AssemblyInformationalVersion( " 0.0.0.0" ) >]
14
+ ()
Original file line number Diff line number Diff line change
1
+ ''------------------------------------------------------------------------------
2
+ '' <auto-generated>
3
+ '' This code was generated by GitVersion.
4
+ ''
5
+ '' You can modify this code as we will not overwrite it when re-executing GitVersion
6
+ '' </auto-generated>
7
+ ''------------------------------------------------------------------------------
8
+
9
+ Imports System.Reflection
10
+
11
+ < assembly : AssemblyFileVersion( "0.0.0.0" )>
12
+ < assembly : AssemblyVersion( "0.0.0.0" )>
13
+ < assembly : AssemblyInformationalVersion( "0.0.0.0" )>
Original file line number Diff line number Diff line change @@ -205,6 +205,27 @@ public void update_assembly_info_with_relative_filename()
205
205
arguments . UpdateAssemblyInfoFileName . ShouldBe ( "..\\ ..\\ CommonAssemblyInfo.cs" ) ;
206
206
}
207
207
208
+ [ Test ]
209
+ public void ensure_assembly_info_true_when_found ( )
210
+ {
211
+ var arguments = ArgumentParser . ParseArguments ( "-ensureAssemblyInfo" ) ;
212
+ arguments . EnsureAssemblyInfo . ShouldBe ( true ) ;
213
+ }
214
+
215
+ [ Test ]
216
+ public void ensure_assembly_info_true ( )
217
+ {
218
+ var arguments = ArgumentParser . ParseArguments ( "-ensureAssemblyInfo true" ) ;
219
+ arguments . EnsureAssemblyInfo . ShouldBe ( true ) ;
220
+ }
221
+
222
+ [ Test ]
223
+ public void ensure_assembly_info_false ( )
224
+ {
225
+ var arguments = ArgumentParser . ParseArguments ( "-ensureAssemblyInfo false" ) ;
226
+ arguments . EnsureAssemblyInfo . ShouldBe ( false ) ;
227
+ }
228
+
208
229
[ Test ]
209
230
public void dynamicRepoLocation ( )
210
231
{
You can’t perform that action at this time.
0 commit comments