Skip to content

Commit 96f10dc

Browse files
committed
提交
1 parent e65bb90 commit 96f10dc

File tree

2 files changed

+6
-20
lines changed

2 files changed

+6
-20
lines changed

src/SmartCode.Generator/GeneratorProjectBuilder.cs

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,6 @@ public async Task Build()
3030
var dataSource = _pluginManager.Resolve<IDataSource>(_project.DataSource.Name);
3131
await dataSource.InitData();
3232

33-
//foreach (var buildKV in _project.BuildTasks)
34-
//{
35-
// _logger.LogInformation($"-------- BuildTask:{buildKV.Key} Start! ---------");
36-
// var output = buildKV.Value.Output;
37-
// var buildContext = new BuildContext
38-
// {
39-
// PluginManager = _pluginManager,
40-
// Project = _project,
41-
// DataSource = dataSource,
42-
// BuildKey = buildKV.Key,
43-
// Build = buildKV.Value,
44-
// Output = output?.Copy()
45-
// };
46-
// await _pluginManager.Resolve<IBuildTask>(buildKV.Value.Type).Build(buildContext);
47-
// _logger.LogInformation($"-------- BuildTask:{buildKV.Key} End! ---------");
48-
//}
4933
BuildContext[] contexts = _project.BuildTasks.Select(d => new BuildContext
5034
{
5135
PluginManager = _pluginManager,
@@ -57,21 +41,24 @@ public async Task Build()
5741
}).ToArray();
5842
foreach (var context in contexts)
5943
{
60-
context.DependOn = contexts.Where(d => d.Build.DependOn.Contains(d.BuildKey)).ToArray();
44+
context.DependOn = contexts.Where(d => context.Build.DependOn != null && context.Build.DependOn.Contains(d.BuildKey)).ToArray();
6145
}
46+
6247
countdown.Reset();
6348
foreach (var context in contexts)
6449
{
65-
context.BuildTask = Task.Factory.StartNew(this.BuildTask, null, TaskCreationOptions.LongRunning);
50+
context.BuildTask = Task.Factory.StartNew(this.BuildTask, context, TaskCreationOptions.LongRunning);
6651
}
6752

6853
countdown.Signal();
54+
55+
await Task.WhenAll(contexts.Select(d => d.BuildTask).ToArray());
6956
}
7057
private async void BuildTask(object obj)
7158
{
72-
countdown.Wait();
7359
var context = (BuildContext)obj;
7460
_logger.LogInformation($"-------- BuildTask:{context.BuildKey} Wait! ---------");
61+
countdown.Wait();
7562
//等待依赖任务
7663
if (context.DependOn != null)
7764
{

src/SmartCode/BuildContext.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ public void SetItem(string key, object item)
2929
}
3030

3131
public IEnumerable<BuildContext> DependOn { get; set; }
32-
public IEnumerable<BuildContext> Next { get; set; }
3332
public Task BuildTask { get; set; }
3433
}
3534
}

0 commit comments

Comments
 (0)