Skip to content
Merged
Show file tree
Hide file tree
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
11 changes: 4 additions & 7 deletions src/Build.UnitTests/BackEnd/MSBuild_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,13 @@ public void Dispose()
/// throw a path too long exception
/// </summary>
[Fact]
[ActiveIssue("https://github.com/dotnet/msbuild/issues/4247")]
public void ProjectItemSpecTooLong()
{
string currentDirectory = Directory.GetCurrentDirectory();
try
{
Directory.SetCurrentDirectory(Path.GetTempPath());

string tempPath = Path.GetTempPath();

string tempProject = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project DefaultTargets=`TargetA; TargetB; TargetC` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>

Expand All @@ -68,16 +65,16 @@ public void ProjectItemSpecTooLong()
projectFile1 += "..\\";
}

int rootLength = Path.GetPathRoot(tempPath).Length;
string tempPathNoRoot = tempPath.Substring(rootLength);
int rootLength = Path.GetPathRoot(tempProject).Length;
string tempPathNoRoot = tempProject.Substring(rootLength);

projectFile1 += Path.Combine(tempPathNoRoot, fileName);
projectFile1 += tempPathNoRoot;

string parentProjectContents = @"
<Project ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>

<Target Name=`Build`>
<MSBuild Projects=`" + projectFile1 + @"` />
<MSBuild Projects=`" + projectFile1 + @"`/>
</Target>
</Project>";
try
Expand Down
6 changes: 4 additions & 2 deletions src/MSBuild.UnitTests/XMake_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Xml.Linq;
using Microsoft.Build.CommandLine;
using Microsoft.Build.Evaluation;
using Microsoft.Build.Framework;
Expand Down Expand Up @@ -985,8 +986,8 @@ public void ConfigurationInvalid()
var msbuildExeName = Path.GetFileName(RunnerUtilities.PathToCurrentlyRunningMsBuildExe);
var newPathToMSBuildExe = Path.Combine(startDirectory, msbuildExeName);
var pathToConfigFile = Path.Combine(startDirectory, msbuildExeName + ".config");

string configContent = @"<?xml version =""1.0""?>
XElement configRuntimeElement = XDocument.Load(RunnerUtilities.PathToCurrentlyRunningMsBuildExe + ".config").Root.Element("runtime");
string configContent = $@"<?xml version =""1.0""?>
<configuration>
<configSections>
<section name=""msbuildToolsets"" type=""Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"" />
Expand All @@ -1006,6 +1007,7 @@ public void ConfigurationInvalid()
<foo/>
</msbuildToolsets>
<foo/>
{configRuntimeElement}
</configuration>";
File.WriteAllText(pathToConfigFile, configContent);

Expand Down
6 changes: 5 additions & 1 deletion src/Shared/FileSystem/WindowsFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ public override bool DirectoryExists(string path)

public override bool FileExists(string path)
{
return NativeMethodsShared.FileExistsWindows(path);
#if NETFRAMEWORK
return Microsoft.IO.File.Exists(path);
#else
return File.Exists(path);
#endif
}

public override bool FileOrDirectoryExists(string path)
Expand Down
9 changes: 3 additions & 6 deletions src/Tasks.UnitTests/MSBuild_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,13 @@ public void Dispose()
/// throw a path too long exception
/// </summary>
[Fact]
[ActiveIssue("https://github.com/dotnet/msbuild/issues/4247")]
public void ProjectItemSpecTooLong()
{
string currentDirectory = Directory.GetCurrentDirectory();
try
{
Directory.SetCurrentDirectory(Path.GetTempPath());

string tempPath = Path.GetTempPath();

string tempProject = ObjectModelHelpers.CreateTempFileOnDisk(@"
<Project DefaultTargets=`TargetA; TargetB; TargetC` ToolsVersion=`msbuilddefaulttoolsversion` xmlns=`msbuildnamespace`>

Expand All @@ -70,10 +67,10 @@ public void ProjectItemSpecTooLong()
projectFile1 += "..\\";
}

int rootLength = Path.GetPathRoot(tempPath).Length;
string tempPathNoRoot = tempPath.Substring(rootLength);
int rootLength = Path.GetPathRoot(tempProject).Length;
string tempPathNoRoot = tempProject.Substring(rootLength);

projectFile1 += Path.Combine(tempPathNoRoot, fileName);
projectFile1 += tempPathNoRoot;
try
{
MSBuild msbuildTask = new MSBuild
Expand Down