Writes the solution file to disk. Raises: IndexError: An entry appears multiple times.
(self, writer=gyp.common.WriteOnDiff)
| 228 | self.Write() |
| 229 | |
| 230 | def Write(self, writer=gyp.common.WriteOnDiff): |
| 231 | """Writes the solution file to disk. |
| 232 | |
| 233 | Raises: |
| 234 | IndexError: An entry appears multiple times. |
| 235 | """ |
| 236 | # Walk the entry tree and collect all the folders and projects. |
| 237 | all_entries = set() |
| 238 | entries_to_check = self.entries[:] |
| 239 | while entries_to_check: |
| 240 | e = entries_to_check.pop(0) |
| 241 | |
| 242 | # If this entry has been visited, nothing to do. |
| 243 | if e in all_entries: |
| 244 | continue |
| 245 | |
| 246 | all_entries.add(e) |
| 247 | |
| 248 | # If this is a folder, check its entries too. |
| 249 | if isinstance(e, MSVSFolder): |
| 250 | entries_to_check += e.entries |
| 251 | |
| 252 | all_entries = sorted(all_entries, key=attrgetter("path")) |
| 253 | |
| 254 | # Open file and print header |
| 255 | f = writer(self.path) |
| 256 | f.write( |
| 257 | "Microsoft Visual Studio Solution File, " |
| 258 | "Format Version %s\r\n" % self.version.SolutionVersion() |
| 259 | ) |
| 260 | f.write("# %s\r\n" % self.version.Description()) |
| 261 | |
| 262 | # Project entries |
| 263 | sln_root = os.path.split(self.path)[0] |
| 264 | for e in all_entries: |
| 265 | relative_path = gyp.common.RelativePath(e.path, sln_root) |
| 266 | # msbuild does not accept an empty folder_name. |
| 267 | # use '.' in case relative_path is empty. |
| 268 | folder_name = relative_path.replace("/", "\\") or "." |
| 269 | f.write( |
| 270 | 'Project("%s") = "%s", "%s", "%s"\r\n' |
| 271 | % ( |
| 272 | e.entry_type_guid, # Entry type GUID |
| 273 | e.name, # Folder name |
| 274 | folder_name, # Folder name (again) |
| 275 | e.get_guid(), # Entry GUID |
| 276 | ) |
| 277 | ) |
| 278 | |
| 279 | # TODO(rspangler): Need a way to configure this stuff |
| 280 | if self.websiteProperties: |
| 281 | f.write( |
| 282 | "\tProjectSection(WebsiteProperties) = preProject\r\n" |
| 283 | '\t\tDebug.AspNetCompiler.Debug = "True"\r\n' |
| 284 | '\t\tRelease.AspNetCompiler.Debug = "False"\r\n' |
| 285 | "\tEndProjectSection\r\n" |
| 286 | ) |
| 287 |
no test coverage detected