Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
#nullable enable
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
Expand All @@ -9,8 +10,8 @@ namespace Xamarin.ProjectTools
public class SolutionBuilder : Builder
{
public IList<XamarinProject> Projects { get; }
public string SolutionPath { get; set; }
public string SolutionName { get; set; }
public string? SolutionPath { get; set; }
public string SolutionName { get; set; } = "";
public bool BuildSucceeded { get; set; }
Comment on lines 12 to 15

public SolutionBuilder (string solutionName) : base()
Expand All @@ -21,6 +22,7 @@ public SolutionBuilder (string solutionName) : base()

public void Save ()
{
ArgumentNullException.ThrowIfNull (SolutionPath);
foreach (var p in Projects) {
using (var pb = new ProjectBuilder (Path.Combine (SolutionPath, p.ProjectName))) {
pb.Save (p);
Expand Down Expand Up @@ -65,6 +67,7 @@ public void Save ()

public bool BuildProject(XamarinProject project, string target = "Build")
{
ArgumentNullException.ThrowIfNull (SolutionPath);
BuildSucceeded = BuildInternal(Path.Combine (SolutionPath, project.ProjectName, project.ProjectFilePath), target, restore: project.ShouldRestorePackageReferences);
return BuildSucceeded;
}
Expand Down Expand Up @@ -93,7 +96,7 @@ public bool Clean(params string[] parameters)
protected override void Dispose (bool disposing)
{
if (disposing)
if (BuildSucceeded)
if (BuildSucceeded && !string.IsNullOrEmpty (SolutionPath))
try {
Directory.Delete (SolutionPath, recursive: true);
} catch (Exception) {
Expand Down