Skip to content

Commit 28d2ad2

Browse files
authored
Stop loading Microsoft.DevDiv files as read-only (#7007)
1 parent 115b58c commit 28d2ad2

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

src/Build/ElementLocation/XmlDocumentWithLocation.cs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -352,24 +352,17 @@ private void DetermineWhetherToLoadReadOnly(string fullPath)
352352
// Only files from Microsoft
353353
if (Path.GetFileName(fullPath).StartsWith("Microsoft.", StringComparison.OrdinalIgnoreCase))
354354
{
355-
// If we are loading devdiv targets, we're in razzle
356-
if (Path.GetFileName(fullPath).StartsWith("Microsoft.DevDiv", StringComparison.OrdinalIgnoreCase))
357-
{
358-
_loadAsReadOnly = true;
359-
}
360-
else // Else, only load if they're in program files or windows directories
361-
{
362-
ErrorUtilities.VerifyThrow(Path.IsPathRooted(fullPath), "should be full path");
363-
string directory = Path.GetDirectoryName(fullPath);
355+
// Load read-only if they're in program files or windows directories
356+
ErrorUtilities.VerifyThrow(Path.IsPathRooted(fullPath), "should be full path");
357+
string directory = Path.GetDirectoryName(fullPath);
364358

365-
string windowsFolder = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
359+
string windowsFolder = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
366360

367-
if ((!String.IsNullOrEmpty(windowsFolder) && directory.StartsWith(windowsFolder, StringComparison.OrdinalIgnoreCase)) ||
368-
(!String.IsNullOrEmpty(FrameworkLocationHelper.programFiles32) && directory.StartsWith(FrameworkLocationHelper.programFiles32, StringComparison.OrdinalIgnoreCase)) ||
369-
(!String.IsNullOrEmpty(FrameworkLocationHelper.programFiles64) && directory.StartsWith(FrameworkLocationHelper.programFiles64, StringComparison.OrdinalIgnoreCase)))
370-
{
371-
_loadAsReadOnly = true;
372-
}
361+
if ((!String.IsNullOrEmpty(windowsFolder) && directory.StartsWith(windowsFolder, StringComparison.OrdinalIgnoreCase)) ||
362+
(!String.IsNullOrEmpty(FrameworkLocationHelper.programFiles32) && directory.StartsWith(FrameworkLocationHelper.programFiles32, StringComparison.OrdinalIgnoreCase)) ||
363+
(!String.IsNullOrEmpty(FrameworkLocationHelper.programFiles64) && directory.StartsWith(FrameworkLocationHelper.programFiles64, StringComparison.OrdinalIgnoreCase)))
364+
{
365+
_loadAsReadOnly = true;
373366
}
374367
}
375368
}

0 commit comments

Comments
 (0)