forked from mensagymnazium/IntranetGen3
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetupSolution.ps1
More file actions
26 lines (22 loc) · 1.78 KB
/
Copy pathSetupSolution.ps1
File metadata and controls
26 lines (22 loc) · 1.78 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
param (
[string]$NewFullName = "MensaGymnazium.IntranetGen3",
[string]$NewSolutionName = "IntranetGen3",
[string]$NewWebProjectPort = "44319",
[string]$OriginalSolutionName = "IntranetGen3",
[string]$OriginalWebProjectPort = "44319",
[string]$OriginalFullName = "MensaGymnazium.IntranetGen3"
)
[string]$SolutionFolder = [System.IO.Path]::GetDirectoryName($MyInvocation.MyCommand.Path);
Get-ChildItem -recurse $SolutionFolder -include *.cs,*.csproj,*.config,*.ps1,*.json,*.tsx,*.cshtml,*.props,*.razor,*.json,*.html,*.js | where { $_ -is [System.IO.FileInfo] } | where { !$_.FullName.Contains("\packages\") } | where { !$_.FullName.Contains("\obj\") } | where { !$_.FullName.Contains("package.json") } | where { !$_.Name.Equals("_SetApplicationName.ps1") } |
Foreach-Object {
Set-ItemProperty $_.FullName -name IsReadOnly -value $false
[string]$Content = [IO.File]::ReadAllText($_.FullName)
$Content = $Content.Replace($OriginalFullName, $NewFullName)
$Content = $Content.Replace($OriginalSolutionName, $NewSolutionName)
$Content = $Content.Replace($OriginalWebProjectPort, $NewWebProjectPort)
[IO.File]::WriteAllText($_.FullName, $Content, [System.Text.Encoding]::UTF8)
}
Rename-Item -path ([System.IO.Path]::Combine($SolutionFolder, $OriginalSolutionName + '.sln')) -newName ($NewSolutionName + '.sln')
Rename-Item -path ([System.IO.Path]::Combine($SolutionFolder, 'Entity\IntranetGen3DbContext.cs')) -newName ($NewSolutionName + 'DbContext.cs')
Rename-Item -path ([System.IO.Path]::Combine($SolutionFolder, 'Entity\IntranetGen3DesignTimeDbContextFactory.cs')) -newName ($NewSolutionName + 'DesignTimeDbContextFactory.cs')
Rename-Item -path ([System.IO.Path]::Combine($SolutionFolder, 'Entity.Tests\IntranetGen3DbContextTests.cs')) -newName ($NewSolutionName + 'DbContextTests.cs')