-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathyaml2code.ps1
More file actions
40 lines (31 loc) · 1.21 KB
/
yaml2code.ps1
File metadata and controls
40 lines (31 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# Import-Module powershell-yaml
param
(
$yamlFile = "cqrs.yaml"
)
[string[]]$fileContent = Get-Content $yamlFile
$content = ''
foreach ($line in $fileContent) { $content = $content + "`n" + $line }
$yaml = ConvertFrom-YAML $content
$guid = New-Guid
$solution = $guid.Guid.ToString()
# $solution = $yaml["solution"] briefly commented this out to avoid the pain of rebuilding
$projects = $yaml["projects"]
mkdir $solution
dotnet new sln -o "$solution"
foreach ($project in $projects) {
$projectName = $project.name
$template = if ($null -eq $project.template) { "classlib" } else { $project.template }
dotnet new $template --no-restore -o "$solution/$projectName"
dotnet sln "$solution/$solution.sln" add "$solution/$projectName/$projectName.csproj"
foreach ($reference in $project.references) {
dotnet add "$solution/$projectName/$projectName.csproj" reference "$solution/$reference/$reference.csproj"
}
foreach ($package in $project.packages) {
dotnet add "$solution/$projectName/$projectName.csproj" package $package
}
foreach ($feature in $project.features) {
$featureName = "Features/$($feature.keys[0]).ps1"
Invoke-Expression -Command $featureName
}
}