Skip to content

Commit eb3a57d

Browse files
committed
Throw exception if a solution reference a not exist csproj.
1 parent 2aa2a11 commit eb3a57d

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

tools/CreateFilterMappings.ps1

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ function Create-ProjectToFullPathMappings
9696
$CsprojFiles = Get-ChildItem -Path $ServiceFolder -Filter "*.csproj" -Recurse
9797
foreach ($CsprojFile in $CsprojFiles)
9898
{
99+
if ($Mappings.Contains($CsprojFile.BaseName))
100+
{
101+
throw ($CsprojFile.FullName + " is conflicts with " + $Mappings[$CsprojFile.BaseName])
102+
}
99103
$Mappings[$CsprojFile.BaseName] = $CsprojFile.FullName
100104
}
101105
}
@@ -149,10 +153,24 @@ function Add-ProjectDependencies
149153
)
150154

151155
$CommonProjectsToIgnore = @("ScenarioTest.ResourceManager", "TestFx", "Tests" )
152-
$ProjectDependencies = @()
156+
$CsprojList = @()
153157
$Content = Get-Content -Path $SolutionPath
154-
$Content | Select-String -Pattern "[`\`/]*[a-zA-Z0-9.]*.csproj" | ForEach-Object { $_.Matches[0].Value.Replace(".csproj", "") } | Where-Object { $CommonProjectsToIgnore -notcontains $_ } | ForEach-Object { $ProjectDependencies += $_ }
155-
$Mappings[$SolutionPath] = $ProjectDependencies
158+
$SolutionFoloderPath = Split-Path -Parent $SolutionPath
159+
$Content | Select-String -Pattern "`"[a-zA-Z0-9`.`\\`/]*.csproj`"" | ForEach-Object { $_.Matches[0].Value.Trim('"') } | Where-Object { $CommonProjectsToIgnore -notcontains $_ } | ForEach-Object { $CsprojList += $_ }
160+
161+
foreach ($Csproj in $CsprojList)
162+
{
163+
try
164+
{
165+
$CsprojAbslutionPath = Resolve-Path -Path ($SolutionFoloderPath + "\" + $Csproj)
166+
Write-Host $CsprojAbslutionPath
167+
}
168+
catch
169+
{
170+
throw "${SolutionPath}: $Csproj is not found!"
171+
}
172+
}
173+
$Mappings[$SolutionPath] = $CsprojList | ForEach-Object { (Split-Path -Path $_ -Leaf).Trim('.csproj') }
156174
return $Mappings
157175
}
158176

@@ -292,10 +310,6 @@ function Add-CsprojMappings
292310
{
293311
$Values.Add($TempValue) | Out-Null
294312
}
295-
else
296-
{
297-
Throw "${ProjectNameFromSolution}: $ReferencedProject.csproj is not found!"
298-
}
299313
}
300314
}
301315
}

0 commit comments

Comments
 (0)