'Writes the solution file to disk.
Raises:
IndexError: An entry appears multiple times.'

def Write(self, writer=gyp.common.WriteOnDiff):

    all_entries = set()
    entries_to_check = self.entries[:]
    while entries_to_check:
        e = entries_to_check.pop(0)
        if (e in all_entries):
            continue
        all_entries.add(e)
        if isinstance(e, MSVSFolder):
            entries_to_check += e.entries
    all_entries = sorted(all_entries)
    f = writer(self.path)
    f.write(('Microsoft    Visual    Studio    Solution    File,    Format    Version    %s\r\n' % self.version.SolutionVersion()))
    f.write(('#    %s\r\n' % self.version.Description()))
    sln_root = os.path.split(self.path)[0]
    for e in all_entries:
        relative_path = gyp.common.RelativePath(e.path, sln_root)
        folder_name = (relative_path.replace('/', '\\') or '.')
        f.write(('Project("%s")    =    "%s",    "%s",    "%s"\r\n' % (e.entry_type_guid, e.name, folder_name, e.get_guid())))
        if self.websiteProperties:
            f.write(' DCTB ProjectSection(WebsiteProperties)    =    preProject\r\n DCTB  DCTB Debug.AspNetCompiler.Debug    =    "True"\r\n DCTB  DCTB Release.AspNetCompiler.Debug    =    "False"\r\n DCTB EndProjectSection\r\n')
        if isinstance(e, MSVSFolder):
            if e.items:
                f.write(' DCTB ProjectSection(SolutionItems)    =    preProject\r\n')
                for i in e.items:
                    f.write((' DCTB  DCTB %s    =    %s\r\n' % (i, i)))
                f.write(' DCTB EndProjectSection\r\n')
        if isinstance(e, MSVSProject):
            if e.dependencies:
                f.write(' DCTB ProjectSection(ProjectDependencies)    =    postProject\r\n')
                for d in e.dependencies:
                    f.write((' DCTB  DCTB %s    =    %s\r\n' % (d.get_guid(), d.get_guid())))
                f.write(' DCTB EndProjectSection\r\n')
        f.write('EndProject\r\n')
    f.write('Global\r\n')
    f.write(' DCTB GlobalSection(SolutionConfigurationPlatforms)    =    preSolution\r\n')
    for v in self.variants:
        f.write((' DCTB  DCTB %s    =    %s\r\n' % (v, v)))
    f.write(' DCTB EndGlobalSection\r\n')
    config_guids = []
    config_guids_overrides = {}
    for e in all_entries:
        if isinstance(e, MSVSProject):
            config_guids.append(e.get_guid())
            config_guids_overrides[e.get_guid()] = e.config_platform_overrides
    config_guids.sort()
    f.write(' DCTB GlobalSection(ProjectConfigurationPlatforms)    =    postSolution\r\n')
    for g in config_guids:
        for v in self.variants:
            nv = config_guids_overrides[g].get(v, v)
            f.write((' DCTB  DCTB %s.%s.ActiveCfg    =    %s\r\n' % (g, v, nv)))
            f.write((' DCTB  DCTB %s.%s.Build.0    =    %s\r\n' % (g, v, nv)))
    f.write(' DCTB EndGlobalSection\r\n')
    f.write(' DCTB GlobalSection(SolutionProperties)    =    preSolution\r\n')
    f.write(' DCTB  DCTB HideSolutionNode    =    FALSE\r\n')
    f.write(' DCTB EndGlobalSection\r\n')
    if any([e.entries for e in all_entries if isinstance(e, MSVSFolder)]):
        f.write(' DCTB GlobalSection(NestedProjects)    =    preSolution\r\n')
        for e in all_entries:
            if (not isinstance(e, MSVSFolder)):
                continue
            for subentry in e.entries:
                f.write((' DCTB  DCTB %s    =    %s\r\n' % (subentry.get_guid(), e.get_guid())))
        f.write(' DCTB EndGlobalSection\r\n')
    f.write('EndGlobal\r\n')
    f.close()
