Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Thanks to MerickOWA for posting here, I am sure it saved me hours with the same problem.</p> <p>I have created a PowerShell script to find the mismatched GUIDs for all projects in a solution. It may save someone else even more hours.</p> <p>To run it, copy the code below into a text file in the same folder as your solution, rename to .ps1, start up the Powershell console, navigate to the folder containing you solution, then run the script. It will list mis-matched project references, if any. </p> <p>To fix, open the solution in Visual Studio then remove and re-add the mismatched Project Reference(s).</p> <pre><code>function validateSolution([string]$slnFileName) { "Validating solution: " + $slnFileName # Extract all the c# projects from the solution file $solutionProjects = Get-Content $slnFileName | Select-String 'Project\(' | ForEach-Object { $projectParts = $_ -Split '[,=]' ; New-Object PSObject -Property @{ Kind = $projectParts[0].Replace('Project("', '').Replace('") ',''); Name = $projectParts[1].Trim('" '); File = $projectParts[2].Trim('" '); Guid = $projectParts[3].Trim('" '); }; } | Where-Object { $_.Kind -eq "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" } # Kind = C# project # Output list of C# projects to console # $solutionProjects # Create HashTable keyed on project GUID $solutionProjectGuids = @{} foreach ($project in $solutionProjects) { $solutionProjectGuids.Add($project.Guid, $project) } # Loop through each c# project in the solution foreach ($project in $solutionProjects) { [xml]$projectXml = Get-Content $project.File $projectReferences = $projectXml.Project.ItemGroup | Where-Object { $_.ProjectReference -ne $null } # Loop through each ProjectReference foreach($reference in $projectReferences.ChildNodes | Where-Object { $_.Project -ne $null } ) { # Check the project reference GUID exists in hash table of project GUIDS; if not write error if (!$solutionProjectGuids.ContainsKey($reference.Project)) { "" "Bad ProjectReference: Project GUID not found in solution " "Solution: " + $slnFileName "Project: " + $project.File "Reference: " + $reference.Name "Bad GUID: " + $reference.Project } } } "Completed solution: " + $slnFileName } foreach ($solutionFile in ls *.sln) { validateSolution $solutionFile } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload