diff --git a/00_Utilities/DotnetUtils/DotnetUtils/Methods.cs b/00_Utilities/DotnetUtils/DotnetUtils/Methods.cs
index de69131f..2aafa800 100644
--- a/00_Utilities/DotnetUtils/DotnetUtils/Methods.cs
+++ b/00_Utilities/DotnetUtils/DotnetUtils/Methods.cs
@@ -50,7 +50,7 @@ public sealed record ProcessResult(int ExitCode, string StdOut, string StdErr) {
public override string? ToString() =>
StdOut +
(StdOut is not (null or "") && ExitCode > 0 ? "\n" : "") +
- (ExitCode > 0 ?
+ (ExitCode != 0 ?
$"{ExitCode}\n{StdErr}" :
"");
}
diff --git a/00_Utilities/DotnetUtils/DotnetUtils/PortInfo.cs b/00_Utilities/DotnetUtils/DotnetUtils/PortInfo.cs
index 547e2878..a1caaf15 100644
--- a/00_Utilities/DotnetUtils/DotnetUtils/PortInfo.cs
+++ b/00_Utilities/DotnetUtils/DotnetUtils/PortInfo.cs
@@ -34,7 +34,7 @@ public record PortInfo(
(int?)null;
var gameName =
- parts.Length == 0 ?
+ parts.Length <= 1 ?
null :
specialGameNames.TryGetValue(parts[1], out var specialName) ?
specialName :
diff --git a/00_Utilities/DotnetUtils/DotnetUtils/Program.cs b/00_Utilities/DotnetUtils/DotnetUtils/Program.cs
index f082060c..f9995994 100644
--- a/00_Utilities/DotnetUtils/DotnetUtils/Program.cs
+++ b/00_Utilities/DotnetUtils/DotnetUtils/Program.cs
@@ -184,18 +184,37 @@ void generateMissingSlns() {
void generateMissingProjs() {
foreach (var item in infos.Where(x => !x.Projs.Any())) {
- var (langArg, langVersion) = item.Lang switch {
- "csharp" => ("\"C#\"", 10),
- "vbnet" => ("\"VB\"", 16.9),
+ // We can't use the dotnet command to create a new project using the built-in console template, because part of that template
+ // is a Program.cs / Program.vb file. If there already are code files, there's no need to add a new empty one; and
+ // if there's already such a file, it might try to overwrite it.
+
+ var projText = item.Lang switch {
+ "csharp" => @"
+
+ Exe
+ net6.0
+ 10
+ enable
+ enable
+
+
+",
+ "vbnet" => @$"
+
+ Exe
+ {item.GameName}
+ net6.0
+ 16.9
+
+
+",
_ => throw new InvalidOperationException()
};
-
- var result = RunProcess("dotnet", $"new console --language {langArg} --name {item.GameName}.{item.ProjExt} -o {item.LangPath} -f net6.0 --langversion {langVersion}");
- WriteLine(result);
-
var projFullPath = Combine(item.LangPath, $"{item.GameName}.{item.ProjExt}");
+ File.WriteAllText(projFullPath, projText);
+
if (item.Slns.Length == 1) {
- result = RunProcess("dotnet", $"sln {item.Slns[0]} add {projFullPath}");
+ var result = RunProcess("dotnet", $"sln {item.Slns[0]} add {projFullPath}");
WriteLine(result);
}
}