@@ -30,7 +30,7 @@ public sealed class DependencyManager : IDisposable
30
30
private readonly DotNet dotnet ;
31
31
private readonly FileContent fileContent ;
32
32
private readonly TemporaryDirectory packageDirectory ;
33
- private readonly TemporaryDirectory ? razorWorkingDirectory ;
33
+ private TemporaryDirectory ? razorWorkingDirectory ;
34
34
35
35
36
36
/// <summary>
@@ -136,34 +136,7 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg
136
136
if ( bool . TryParse ( webViewExtractionOption , out var shouldExtractWebViews ) &&
137
137
shouldExtractWebViews )
138
138
{
139
- progressMonitor . LogInfo ( $ "Generating source files from cshtml and razor files.") ;
140
-
141
- var views = GetFiles ( "*.cshtml" )
142
- . Concat ( GetFiles ( "*.razor" ) )
143
- . ToArray ( ) ;
144
-
145
- if ( views . Length > 0 )
146
- {
147
- progressMonitor . LogInfo ( $ "Found { views . Length } cshtml and razor files.") ;
148
-
149
- // TODO: use SDK specified in global.json
150
- var sdk = new Sdk ( dotnet ) . GetNewestSdk ( ) ;
151
- if ( sdk != null )
152
- {
153
- try
154
- {
155
- var razor = new Razor ( sdk , dotnet , progressMonitor ) ;
156
- razorWorkingDirectory = new TemporaryDirectory ( ComputeTempDirectory ( sourceDir . FullName , "razor" ) ) ;
157
- var generatedFiles = razor . GenerateFiles ( views , usedReferences . Keys , razorWorkingDirectory . ToString ( ) ) ;
158
- this . allSources . AddRange ( generatedFiles ) ;
159
- }
160
- catch ( Exception ex )
161
- {
162
- // It's okay, we tried our best to generate source files from cshtml files.
163
- progressMonitor . LogInfo ( $ "Failed to generate source files from cshtml files: { ex . Message } ") ;
164
- }
165
- }
166
- }
139
+ GenerateSourceFilesFromWebViews ( ) ;
167
140
}
168
141
169
142
progressMonitor . Summary (
@@ -178,6 +151,38 @@ public DependencyManager(string srcDir, IDependencyOptions options, ILogger logg
178
151
DateTime . Now - startTime ) ;
179
152
}
180
153
154
+ private void GenerateSourceFilesFromWebViews ( )
155
+ {
156
+ progressMonitor . LogInfo ( $ "Generating source files from cshtml and razor files.") ;
157
+
158
+ var views = GetFiles ( "*.cshtml" )
159
+ . Concat ( GetFiles ( "*.razor" ) )
160
+ . ToArray ( ) ;
161
+
162
+ if ( views . Length > 0 )
163
+ {
164
+ progressMonitor . LogInfo ( $ "Found { views . Length } cshtml and razor files.") ;
165
+
166
+ // TODO: use SDK specified in global.json
167
+ var sdk = new Sdk ( dotnet ) . GetNewestSdk ( ) ;
168
+ if ( sdk != null )
169
+ {
170
+ try
171
+ {
172
+ var razor = new Razor ( sdk , dotnet , progressMonitor ) ;
173
+ razorWorkingDirectory = new TemporaryDirectory ( ComputeTempDirectory ( sourceDir . FullName , "razor" ) ) ;
174
+ var generatedFiles = razor . GenerateFiles ( views , usedReferences . Keys , razorWorkingDirectory . ToString ( ) ) ;
175
+ this . allSources . AddRange ( generatedFiles ) ;
176
+ }
177
+ catch ( Exception ex )
178
+ {
179
+ // It's okay, we tried our best to generate source files from cshtml files.
180
+ progressMonitor . LogInfo ( $ "Failed to generate source files from cshtml files: { ex . Message } ") ;
181
+ }
182
+ }
183
+ }
184
+ }
185
+
181
186
public DependencyManager ( string srcDir ) : this ( srcDir , DependencyOptions . Default , new ConsoleLogger ( Verbosity . Info ) ) { }
182
187
183
188
private IEnumerable < string > GetFiles ( string pattern , bool recurseSubdirectories = true )
0 commit comments