Skip to content

Commit

Permalink
(cake-buildGH-2314) Allow setting MSBuild Platform using custom string
Browse files Browse the repository at this point in the history
  • Loading branch information
augustoproiete committed Mar 4, 2021
1 parent 9b3c0f8 commit 6b24caf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,36 @@ public void Should_Return_The_Same_Configuration()
}
}

public sealed class TheSetPlatformTargetStringMethod
{
[Fact]
public void Should_Set_Platform_Target_Via_Property()
{
// Given
var settings = new MSBuildSettings();

// When
settings.SetPlatformTarget("Custom");

// Then
Assert.True(settings.Properties.ContainsKey("Platform"));
Assert.Equal("Custom", string.Join(string.Empty, settings.Properties["Platform"]));
}

[Fact]
public void Should_Return_The_Same_Configuration()
{
// Given
var settings = new MSBuildSettings();

// When
var result = settings.SetPlatformTarget("Custom");

// Then
Assert.Equal(settings, result);
}
}

public sealed class TheWithPropertyMethod
{
[Fact]
Expand Down
17 changes: 17 additions & 0 deletions src/Cake.Common/Tools/MSBuild/MSBuildSettingsExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ public static MSBuildSettings SetPlatformTarget(this MSBuildSettings settings, P
return settings;
}

/// <summary>
/// Sets the platform target.
/// </summary>
/// <param name="settings">The settings.</param>
/// <param name="target">The target.</param>
/// <returns>The same <see cref="MSBuildSettings"/> instance so that multiple calls can be chained.</returns>
public static MSBuildSettings SetPlatformTarget(this MSBuildSettings settings, string target)
{
if (settings == null)
{
throw new ArgumentNullException(nameof(settings));
}

settings.WithProperty("Platform", target);
return settings;
}

/// <summary>
/// Sets the MSBuild platform.
/// </summary>
Expand Down

0 comments on commit 6b24caf

Please sign in to comment.