@@ -14,14 +14,26 @@ class AssemblyInfoFileUpdate : IDisposable
14
14
List < Action > restoreBackupTasks = new List < Action > ( ) ;
15
15
List < Action > cleanupBackupTasks = new List < Action > ( ) ;
16
16
17
- public AssemblyInfoFileUpdate ( Arguments args , string workingDirectory , VersionVariables variables , IFileSystem fileSystem )
17
+ ISet < string > updateAssemblyInfoFileName ;
18
+ string workingDirectory ;
19
+ VersionVariables variables ;
20
+ IFileSystem fileSystem ;
21
+ bool ensureAssemblyInfo ;
22
+
23
+ public AssemblyInfoFileUpdate ( ISet < string > updateAssemblyInfoFileName , string workingDirectory , VersionVariables variables , IFileSystem fileSystem , bool ensureAssemblyInfo )
18
24
{
19
- if ( ! args . UpdateAssemblyInfo ) return ;
25
+ this . updateAssemblyInfoFileName = updateAssemblyInfoFileName ;
26
+ this . workingDirectory = workingDirectory ;
27
+ this . variables = variables ;
28
+ this . fileSystem = fileSystem ;
29
+ this . ensureAssemblyInfo = ensureAssemblyInfo ;
30
+ }
20
31
21
- if ( args . Output != OutputType . Json )
22
- Logger . WriteInfo ( "Updating assembly info files" ) ;
32
+ public void Update ( )
33
+ {
34
+ Logger . WriteInfo ( "Updating assembly info files" ) ;
23
35
24
- var assemblyInfoFiles = GetAssemblyInfoFiles ( workingDirectory , args , fileSystem ) . ToList ( ) ;
36
+ var assemblyInfoFiles = GetAssemblyInfoFiles ( workingDirectory , updateAssemblyInfoFileName , fileSystem , ensureAssemblyInfo ) . ToList ( ) ;
25
37
Logger . WriteInfo ( $ "Found { assemblyInfoFiles . Count } files") ;
26
38
27
39
var assemblyVersion = variables . AssemblySemVer ;
@@ -90,15 +102,15 @@ static string ReplaceOrAppend(Regex replaceRegex, string inputString, string rep
90
102
}
91
103
92
104
93
- static IEnumerable < FileInfo > GetAssemblyInfoFiles ( string workingDirectory , Arguments args , IFileSystem fileSystem )
105
+ static IEnumerable < FileInfo > GetAssemblyInfoFiles ( string workingDirectory , ISet < string > updateAssemblyInfoFileName , IFileSystem fileSystem , bool ensureAssemblyInfo )
94
106
{
95
- if ( args . UpdateAssemblyInfoFileName != null && args . UpdateAssemblyInfoFileName . Any ( x => ! string . IsNullOrWhiteSpace ( x ) ) )
107
+ if ( updateAssemblyInfoFileName != null && updateAssemblyInfoFileName . Any ( x => ! string . IsNullOrWhiteSpace ( x ) ) )
96
108
{
97
- foreach ( var item in args . UpdateAssemblyInfoFileName )
109
+ foreach ( var item in updateAssemblyInfoFileName )
98
110
{
99
111
var fullPath = Path . Combine ( workingDirectory , item ) ;
100
112
101
- if ( EnsureVersionAssemblyInfoFile ( args , fileSystem , fullPath ) )
113
+ if ( EnsureVersionAssemblyInfoFile ( ensureAssemblyInfo , fileSystem , fullPath , updateAssemblyInfoFileName ) )
102
114
{
103
115
yield return new FileInfo ( fullPath ) ;
104
116
}
@@ -116,11 +128,11 @@ static IEnumerable<FileInfo> GetAssemblyInfoFiles(string workingDirectory, Argum
116
128
}
117
129
}
118
130
119
- static bool EnsureVersionAssemblyInfoFile ( Arguments arguments , IFileSystem fileSystem , string fullPath )
131
+ static bool EnsureVersionAssemblyInfoFile ( bool ensureAssemblyInfo , IFileSystem fileSystem , string fullPath , ISet < string > updateAssemblyInfoFileName )
120
132
{
121
133
if ( fileSystem . Exists ( fullPath ) ) return true ;
122
134
123
- if ( ! arguments . EnsureAssemblyInfo ) return false ;
135
+ if ( ! ensureAssemblyInfo ) return false ;
124
136
125
137
var assemblyInfoSource = AssemblyVersionInfoTemplates . GetAssemblyInfoTemplateFor ( fullPath ) ;
126
138
if ( ! string . IsNullOrWhiteSpace ( assemblyInfoSource ) )
@@ -133,7 +145,7 @@ static bool EnsureVersionAssemblyInfoFile(Arguments arguments, IFileSystem fileS
133
145
fileSystem . WriteAllText ( fullPath , assemblyInfoSource ) ;
134
146
return true ;
135
147
}
136
- Logger . WriteWarning ( $ "No version assembly info template available to create source file '{ arguments . UpdateAssemblyInfoFileName } '") ;
148
+ Logger . WriteWarning ( $ "No version assembly info template available to create source file '{ updateAssemblyInfoFileName } '") ;
137
149
return false ;
138
150
}
139
151
0 commit comments