Bugfix: Replace // with \\ before sending project path to MSBuild

On Windows with network shares, the project path starts with "//" which
MSBuild treats as a command-line switch, causing "Unknown switch"
errors. Replace the first two chars with "\\" to make it a proper UNC
path.
This commit is contained in:
zinefer
2026-02-08 16:10:35 -07:00
parent 56f3e2611d
commit b8aeaf74dc

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