-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-projects.ps1
More file actions
38 lines (35 loc) · 1.24 KB
/
Copy pathupdate-projects.ps1
File metadata and controls
38 lines (35 loc) · 1.24 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
$null = (dotnet --list-sdks | Select-Object -Last 1) -match "^(\d+\.\d+)"
$targetFramework = "net$($matches[1])"
if ($targetFramework -notmatch "^net\d+\.\d+$") {
Write-Host "Could not determine target framework"
return
}
Write-Host "Setting target framework to $targetFramework"
Push-Location $PSScriptRoot
Get-ChildItem -Filter "*.csproj" -Recurse | ForEach-Object {
Push-Location $_.Directory
if ( $_.Name -ne "AoC.Common.csproj" ) {
dotnet add reference ..\..\AoC.Common\AoC.Common.csproj
}
$project = $_.FullName
Write-Host "Checking $project"
[xml] $p = Get-Content $project
$fw = $p.Project.PropertyGroup.TargetFramework
if ($fw -eq $targetFramework) {
Write-Host "Project up-to-date"
Pop-Location
return
}
Write-Host "`tUpgrading project to $targetFramework"
$p.Project.PropertyGroup.TargetFramework = $targetFramework
if (-not $p.Project.PropertyGroup.ImplicitUsings) {
Write-Host "`tEnabling implicit usings"
$usings = $p.CreateElement("ImplicitUsings")
$null = $usings.InnerText = "enable"
$null = $p.Project.PropertyGroup.AppendChild($usings)
}
# Write-Host $p.OuterXml
$p.Save($project)
Pop-Location
}
Pop-Location