Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 9 additions & 16 deletions src/Build/ElementLocation/XmlDocumentWithLocation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,24 +352,17 @@ private void DetermineWhetherToLoadReadOnly(string fullPath)
// Only files from Microsoft
if (Path.GetFileName(fullPath).StartsWith("Microsoft.", StringComparison.OrdinalIgnoreCase))
{
// If we are loading devdiv targets, we're in razzle
if (Path.GetFileName(fullPath).StartsWith("Microsoft.DevDiv", StringComparison.OrdinalIgnoreCase))
{
_loadAsReadOnly = true;
}
else // Else, only load if they're in program files or windows directories
{
ErrorUtilities.VerifyThrow(Path.IsPathRooted(fullPath), "should be full path");
string directory = Path.GetDirectoryName(fullPath);
// Load read-only if they're in program files or windows directories
ErrorUtilities.VerifyThrow(Path.IsPathRooted(fullPath), "should be full path");
string directory = Path.GetDirectoryName(fullPath);

string windowsFolder = Environment.GetFolderPath(Environment.SpecialFolder.Windows);
string windowsFolder = Environment.GetFolderPath(Environment.SpecialFolder.Windows);

if ((!String.IsNullOrEmpty(windowsFolder) && directory.StartsWith(windowsFolder, StringComparison.OrdinalIgnoreCase)) ||
(!String.IsNullOrEmpty(FrameworkLocationHelper.programFiles32) && directory.StartsWith(FrameworkLocationHelper.programFiles32, StringComparison.OrdinalIgnoreCase)) ||
(!String.IsNullOrEmpty(FrameworkLocationHelper.programFiles64) && directory.StartsWith(FrameworkLocationHelper.programFiles64, StringComparison.OrdinalIgnoreCase)))
{
_loadAsReadOnly = true;
}
if ((!String.IsNullOrEmpty(windowsFolder) && directory.StartsWith(windowsFolder, StringComparison.OrdinalIgnoreCase)) ||
(!String.IsNullOrEmpty(FrameworkLocationHelper.programFiles32) && directory.StartsWith(FrameworkLocationHelper.programFiles32, StringComparison.OrdinalIgnoreCase)) ||
(!String.IsNullOrEmpty(FrameworkLocationHelper.programFiles64) && directory.StartsWith(FrameworkLocationHelper.programFiles64, StringComparison.OrdinalIgnoreCase)))
{
_loadAsReadOnly = true;
}
}
}
Expand Down