@ -74,6 +74,7 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -74,6 +74,7 @@ namespace ICSharpCode.SharpDevelop.Project
solutionEntries . Add ( information ) ;
if ( projectInfoDict . ContainsKey ( information . IdGuid ) ) {
// resolve GUID conflicts
SD . Log . WarnFormatted ( "Detected duplicate GUID in .sln file: {0} is used for {1} and {2}" , information . IdGuid , information . ProjectName , projectInfoDict [ information . IdGuid ] . ProjectName ) ;
information . IdGuid = Guid . NewGuid ( ) ;
fixedGuidConflicts = true ;
}
@ -131,9 +132,11 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -131,9 +132,11 @@ namespace ICSharpCode.SharpDevelop.Project
// Now that the project configurations have been set, we can actually load the projects:
int projectsLoaded = 0 ;
foreach ( var projectInfo in solutionEntries ) {
// Make copy of IdGuid just in case the project binding writes to projectInfo.IdGuid
Guid idGuid = projectInfo . IdGuid ;
ISolutionItem solutionItem ;
if ( projectInfo . TypeGuid = = ProjectTypeGuids . SolutionFolder ) {
solutionItem = solutionFolderDict [ projectInfo . I dGuid] ;
solutionItem = solutionFolderDict [ i dGuid] ;
} else {
// Load project:
projectInfo . ActiveProjectConfiguration = projectInfo . ConfigurationMapping . GetProjectConfiguration ( solution . ActiveConfiguration ) ;
@ -141,12 +144,29 @@ namespace ICSharpCode.SharpDevelop.Project
@@ -141,12 +144,29 @@ namespace ICSharpCode.SharpDevelop.Project
using ( projectInfo . ProgressMonitor = progress . CreateSubTask ( 1.0 / projectCount ) ) {
solutionItem = LoadProjectWithErrorHandling ( projectInfo ) ;
}
if ( solutionItem . IdGuid ! = idGuid ) {
Guid projectFileGuid = solutionItem . IdGuid ;
if ( ! projectInfoDict . ContainsKey ( projectFileGuid ) ) {
// We'll use the GUID from the project file.
// Register that GUID in the dictionary to avoid its use by multiple projects.
projectInfoDict . Add ( projectFileGuid , projectInfo ) ;
} else {
// Cannot use GUID from project file due to conflict.
// To fix the problem without potentially introducing new conflicts in other .sln files that contain the project,
// we generate a brand new GUID:
solutionItem . IdGuid = Guid . NewGuid ( ) ;
}
SD . Log . WarnFormatted ( "<ProjectGuid> in project '{0}' is '{1}' and does not match the GUID stored in the solution ({2}). "
+ "The conflict was resolved using the GUID {3}" ,
projectInfo . ProjectName , projectFileGuid , idGuid , solutionItem . IdGuid ) ;
fixedGuidConflicts = true ;
}
projectsLoaded + + ;
progress . Progress = ( double ) projectsLoaded / projectCount ;
}
// Add solutionItem to solution:
SolutionFolder folder ;
if ( guidToParentFolderDict ! = null & & guidToParentFolderDict . TryGetValue ( projectInfo . IdGuid , out folder ) ) {
if ( guidToParentFolderDict ! = null & & guidToParentFolderDict . TryGetValue ( i dGuid, out folder ) ) {
folder . Items . Add ( solutionItem ) ;
} else {
solution . Items . Add ( solutionItem ) ;