-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate.ps1
92 lines (69 loc) · 2.4 KB
/
create.ps1
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
function SaveProject {
[CmdletBinding()]
param(
[xml]$doc,
[string]$path
)
$settings = New-Object -TypeName 'System.Xml.XmlWriterSettings' -Property @{Indent=$true; OmitXmlDeclaration=$true}
$writer = [System.Xml.XmlWriter]::Create($path, $settings)
try
{
$doc.Save($writer)
}
finally
{
$writer.Dispose();
}
}
function AddProjectReference {
[CmdletBinding()]
param(
[xml]$doc,
[string]$path
)
$projReference = $doc.CreateElement('ProjectReference')
$projReference.SetAttribute('Include', $path)
$doc.SelectSingleNode('Project//ItemGroup').AppendChild($projReference)
}
function AddPackageReference {
param (
[xml]$doc,
[string]$package,
[string]$version,
[string]$noWarn
)
$packageReference = $doc.CreateElement('PackageReference')
$packageReference.SetAttribute('Include', $package)
$packageReference.SetAttribute('Version', $version)
$noWarnElem = $doc.CreateElement('NoWarn')
$noWarnElem.InnerText = $noWarn
$packageReference.AppendChild($noWarnElem)
$doc.SelectSingleNode('Project//ItemGroup').AppendChild($packageReference)
}
mkdir 'src'
$n = 30
For ($i = 1; $i -le $n; $i++) {
mkdir "src\ClassLibrary${i}"
[xml]$doc = Get-Content 'template.xml'
for ($j = 1; $j -lt $i; $j++) {
AddProjectReference $doc "..\ClassLibrary${j}\ClassLibrary${j}.csproj"
}
SaveProject $doc "src\ClassLibrary${i}\ClassLibrary${i}.csproj"
}
[xml]$root = Get-Content 'template.xml'
[xml]$rootLeft = Get-Content 'template.xml'
[xml]$rootRight = Get-Content 'template.xml'
AddProjectReference $root "..\RootLeft\RootLeft.csproj"
AddProjectReference $root "..\RootRight\RootRight.csproj"
AddProjectReference $rootLeft "..\ClassLibrary${n}\ClassLibrary${n}.csproj"
AddPackageReference $rootLeft 'Microsoft.EntityFrameworkCore' '6.0.0' 'NU1000'
AddPackageReference $rootLeft 'Microsoft.Extensions.DependencyInjection' '5.0.2' ''
AddProjectReference $rootRight "..\ClassLibrary${n}\ClassLibrary${n}.csproj"
mkdir "src\Root"
mkdir "src\RootLeft"
mkdir "src\RootRight"
SaveProject $root "src\Root\Root.csproj"
SaveProject $rootLeft "src\RootLeft\RootLeft.csproj"
SaveProject $rootRight "src\RootRight\RootRight.csproj"
dotnet new sln --output src --name LotsOfDependencies
dotnet sln src\LotsOfDependencies.sln add (Get-ChildItem -r **/*.csproj)