@@ -39,14 +39,10 @@ public async Task GenerateAsync(AsyncCodeConfiguration configuration)
39
39
throw new ArgumentNullException ( nameof ( configuration ) ) ;
40
40
}
41
41
Logger . Info ( "Generating async code started" ) ;
42
- var props = new Dictionary < string , string >
43
- {
44
- [ "CheckForSystemRuntimeDependency" ] = "true" // needed in order that project references are loaded
45
- } ;
46
- var workspace = MSBuildWorkspace . Create ( props ) ;
47
42
48
43
foreach ( var config in configuration . SolutionConfigurations )
49
44
{
45
+ var workspace = CreateWorkspace ( ) ;
50
46
Logger . Info ( $ "Configuring solution '{ config . Path } ' prior analyzation started") ;
51
47
var solutionData = await CreateSolutionData ( workspace , config ) . ConfigureAwait ( false ) ;
52
48
Logger . Info ( $ "Configuring solution '{ config . Path } ' prior analyzation completed") ;
@@ -59,10 +55,12 @@ public async Task GenerateAsync(AsyncCodeConfiguration configuration)
59
55
{
60
56
await ApplyChanges ( workspace , solutionData . Solution ) . ConfigureAwait ( false ) ;
61
57
}
58
+ workspace . Dispose ( ) ;
62
59
}
63
60
64
61
foreach ( var config in configuration . ProjectConfigurations )
65
62
{
63
+ var workspace = CreateWorkspace ( ) ;
66
64
Logger . Info ( $ "Configuring project '{ config . Path } ' prior analyzation started") ;
67
65
var projectData = await CreateProjectData ( workspace , config ) . ConfigureAwait ( false ) ;
68
66
Logger . Info ( $ "Configuring project '{ config . Path } ' prior analyzation completed") ;
@@ -73,11 +71,21 @@ public async Task GenerateAsync(AsyncCodeConfiguration configuration)
73
71
{
74
72
await ApplyChanges ( workspace , projectData . Project . Solution ) . ConfigureAwait ( false ) ;
75
73
}
74
+ workspace . Dispose ( ) ;
76
75
}
77
76
78
77
Logger . Info ( "Generating async code completed" ) ;
79
78
}
80
79
80
+ private MSBuildWorkspace CreateWorkspace ( )
81
+ {
82
+ var props = new Dictionary < string , string >
83
+ {
84
+ [ "CheckForSystemRuntimeDependency" ] = "true" // needed in order that project references are loaded
85
+ } ;
86
+ return MSBuildWorkspace . Create ( props ) ;
87
+ }
88
+
81
89
private async Task GenerateProject ( ProjectData projectData )
82
90
{
83
91
var analyzeConfig = projectData . Configuration . AnalyzeConfiguration ;
0 commit comments