-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinit.ps1
executable file
·74 lines (55 loc) · 1.83 KB
/
init.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
#!/usr/bin/env pwsh
# .SYNOPSIS
# Inititalize the repository
Param(
# The name of the new solution
[Parameter(Mandatory = $true)]
[string] $SolutionName,
# The project type, used for dotent new
[Parameter(Mandatory = $true)]
[string] $ProjectType,
[Parameter(Mandatory = $true)]
[string] $ProjectName
)
function RemoveSampleProjects {
Get-ChildItem -Recurse -Force *.csproj | ForEach-Object { dotnet sln remove $_ }
Remove-Item -Force -Recurse ./src/NetProject
Remove-Item -Force -Recurse ./src/WebApp
Remove-Item -Force -Recurse ./tests/NetProject.Tests
Remove-Item -Force -Recurse ./tests/WebApp.Tests
}
function RenameSolution {
$solution = "$SolutionName.sln"
Rename-Item -Path ./NetProject.sln -NewName $solution
$cakeScript = Get-Content ./build.cake
$cakeScript = $cakeScript.Replace(
'string solution = "NetProject.sln";',
"string solution = ""$solution"";");
$cakeScript | Out-File "build.cake" -Encoding utf8NoBOM
}
function CreateNewProject {
mkdir "./src/$ProjectName"
mkdir "./tests/$ProjectName.Tests"
Push-Location "./src/$ProjectName"
dotnet new $ProjectType
dotnet add package Roslynator.Formatting.Analyzers
Pop-Location
Push-Location "./tests/$ProjectName.Tests"
dotnet new xunit
dotnet add reference "../../src/$ProjectName"
dotnet add package Roslynator.Formatting.Analyzers
Pop-Location
Get-ChildItem -Recurse *.csproj | ForEach-Object { dotnet sln add $_ }
}
function ReplaceReadme {
Move-Item -Path ./README.template.md -Destination ./README.md -Force
}
ReplaceReadme
RemoveSampleProjects
RenameSolution
CreateNewProject
Remove-Item ./init.ps1
dotnet tool restore
dotnet format
dotnet cake
Write-Output "Commit changes to git to complete initialization."