Merge pull request #116071 from zinefer/bugfix-c-sharp-build-on-windows-network-share

Replace `//` with `\\` before sending project path to MSBuild
This commit is contained in:
Thaddeus Crews 2026-02-11 10:27:08 -06:00
commit c6f1ad6b09
No known key found for this signature in database
GPG key ID: 8C6E5FEB5FC03CCC

View file

@ -154,7 +154,17 @@ namespace GodotTools.Build
arguments.Add(buildInfo.OnlyClean ? "clean" : "build");
// C# Project
arguments.Add(buildInfo.Project);
string projectPath = buildInfo.Project;
if (OperatingSystem.IsWindows())
{
// On Windows, when using a network share path, the path may start with "//"
// which MSBuild will treat like a switch. Convert to "\\" to make it an absolute path.
if (projectPath.StartsWith("//"))
{
projectPath = "\\\\" + projectPath.Substring(2);
}
}
arguments.Add(projectPath);
// `dotnet clean` doesn't recognize these options
if (!buildInfo.OnlyClean)
@ -195,7 +205,17 @@ namespace GodotTools.Build
arguments.Add("publish"); // `dotnet publish` command
// C# Project
arguments.Add(buildInfo.Project);
string projectPath = buildInfo.Project;
if (OperatingSystem.IsWindows())
{
// On Windows, when using a network share path, the path may start with "//"
// which MSBuild will treat like a switch. Convert to "\\" to make it an absolute path.
if (projectPath.StartsWith("//"))
{
projectPath = "\\\\" + projectPath.Substring(2);
}
}
arguments.Add(projectPath);
// Restore
// `dotnet publish` restores by default, unless requested not to