Merge pull request #73015 from raulsntos/dotnet/build-csproj

Build C# csproj instead of the solution
This commit is contained in:
Rémi Verschelde 2023-02-11 15:35:32 +01:00
commit 5a79d55560
No known key found for this signature in database
GPG Key ID: C3336907360768E1
3 changed files with 14 additions and 8 deletions

View File

@ -12,6 +12,7 @@ namespace GodotTools.Build
public sealed partial class BuildInfo : RefCounted // TODO Remove RefCounted once we have proper serialization public sealed partial class BuildInfo : RefCounted // TODO Remove RefCounted once we have proper serialization
{ {
public string Solution { get; private set; } public string Solution { get; private set; }
public string Project { get; private set; }
public string Configuration { get; private set; } public string Configuration { get; private set; }
public string? RuntimeIdentifier { get; private set; } public string? RuntimeIdentifier { get; private set; }
public string? PublishOutputDir { get; private set; } public string? PublishOutputDir { get; private set; }
@ -28,6 +29,7 @@ namespace GodotTools.Build
{ {
return obj is BuildInfo other && return obj is BuildInfo other &&
other.Solution == Solution && other.Solution == Solution &&
other.Project == Project &&
other.Configuration == Configuration && other.RuntimeIdentifier == RuntimeIdentifier && other.Configuration == Configuration && other.RuntimeIdentifier == RuntimeIdentifier &&
other.PublishOutputDir == PublishOutputDir && other.Restore == Restore && other.PublishOutputDir == PublishOutputDir && other.Restore == Restore &&
other.Rebuild == Rebuild && other.OnlyClean == OnlyClean && other.Rebuild == Rebuild && other.OnlyClean == OnlyClean &&
@ -41,6 +43,7 @@ namespace GodotTools.Build
{ {
int hash = 17; int hash = 17;
hash = (hash * 29) + Solution.GetHashCode(); hash = (hash * 29) + Solution.GetHashCode();
hash = (hash * 29) + Project.GetHashCode();
hash = (hash * 29) + Configuration.GetHashCode(); hash = (hash * 29) + Configuration.GetHashCode();
hash = (hash * 29) + (RuntimeIdentifier?.GetHashCode() ?? 0); hash = (hash * 29) + (RuntimeIdentifier?.GetHashCode() ?? 0);
hash = (hash * 29) + (PublishOutputDir?.GetHashCode() ?? 0); hash = (hash * 29) + (PublishOutputDir?.GetHashCode() ?? 0);
@ -57,22 +60,25 @@ namespace GodotTools.Build
private BuildInfo() private BuildInfo()
{ {
Solution = string.Empty; Solution = string.Empty;
Project = string.Empty;
Configuration = string.Empty; Configuration = string.Empty;
} }
public BuildInfo(string solution, string configuration, bool restore, bool rebuild, bool onlyClean) public BuildInfo(string solution, string project, string configuration, bool restore, bool rebuild, bool onlyClean)
{ {
Solution = solution; Solution = solution;
Project = project;
Configuration = configuration; Configuration = configuration;
Restore = restore; Restore = restore;
Rebuild = rebuild; Rebuild = rebuild;
OnlyClean = onlyClean; OnlyClean = onlyClean;
} }
public BuildInfo(string solution, string configuration, string runtimeIdentifier, public BuildInfo(string solution, string project, string configuration, string runtimeIdentifier,
string publishOutputDir, bool restore, bool rebuild, bool onlyClean) string publishOutputDir, bool restore, bool rebuild, bool onlyClean)
{ {
Solution = solution; Solution = solution;
Project = project;
Configuration = configuration; Configuration = configuration;
RuntimeIdentifier = runtimeIdentifier; RuntimeIdentifier = runtimeIdentifier;
PublishOutputDir = publishOutputDir; PublishOutputDir = publishOutputDir;

View File

@ -262,7 +262,7 @@ namespace GodotTools.Build
bool onlyClean = false bool onlyClean = false
) )
{ {
var buildInfo = new BuildInfo(GodotSharpDirs.ProjectSlnPath, configuration, var buildInfo = new BuildInfo(GodotSharpDirs.ProjectSlnPath, GodotSharpDirs.ProjectCsProjPath, configuration,
restore: true, rebuild, onlyClean); restore: true, rebuild, onlyClean);
// If a platform was not specified, try determining the current one. If that fails, let MSBuild auto-detect it. // If a platform was not specified, try determining the current one. If that fails, let MSBuild auto-detect it.
@ -282,7 +282,7 @@ namespace GodotTools.Build
[DisallowNull] string publishOutputDir [DisallowNull] string publishOutputDir
) )
{ {
var buildInfo = new BuildInfo(GodotSharpDirs.ProjectSlnPath, configuration, var buildInfo = new BuildInfo(GodotSharpDirs.ProjectSlnPath, GodotSharpDirs.ProjectCsProjPath, configuration,
runtimeIdentifier, publishOutputDir, restore: true, rebuild: false, onlyClean: false); runtimeIdentifier, publishOutputDir, restore: true, rebuild: false, onlyClean: false);
buildInfo.CustomProperties.Add($"GodotTargetPlatform={platform}"); buildInfo.CustomProperties.Add($"GodotTargetPlatform={platform}");

View File

@ -139,8 +139,8 @@ namespace GodotTools.Build
// `dotnet clean` / `dotnet build` commands // `dotnet clean` / `dotnet build` commands
arguments.Add(buildInfo.OnlyClean ? "clean" : "build"); arguments.Add(buildInfo.OnlyClean ? "clean" : "build");
// Solution // C# Project
arguments.Add(buildInfo.Solution); arguments.Add(buildInfo.Project);
// `dotnet clean` doesn't recognize these options // `dotnet clean` doesn't recognize these options
if (!buildInfo.OnlyClean) if (!buildInfo.OnlyClean)
@ -180,8 +180,8 @@ namespace GodotTools.Build
{ {
arguments.Add("publish"); // `dotnet publish` command arguments.Add("publish"); // `dotnet publish` command
// Solution // C# Project
arguments.Add(buildInfo.Solution); arguments.Add(buildInfo.Project);
// Restore // Restore
// `dotnet publish` restores by default, unless requested not to // `dotnet publish` restores by default, unless requested not to