Skip to content

Commit

Permalink
Merge pull request #4110 from Marusyk/rmarusyk/4109
Browse files Browse the repository at this point in the history
GH-4109: Add PublishReadyToRun to DotNetRestoreSettings
  • Loading branch information
devlead committed Jun 29, 2023
2 parents b8b4626 + 1ffd47f commit 3861561
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
Expand Up @@ -216,6 +216,20 @@ public void Should_Add_ForceEvaluate()
// Then
Assert.Equal($@"restore --force-evaluate", result.Args);
}

[Fact]
public void Should_Add_PublishReadyToRun()
{
// Given
var fixture = new DotNetRestorerFixture();
fixture.Settings.PublishReadyToRun = true;

// When
var result = fixture.Run();

// Then
Assert.Equal("restore -p:PublishReadyToRun=true", result.Args);
}
}
}
}
12 changes: 12 additions & 0 deletions src/Cake.Common/Tools/DotNet/Restore/DotNetRestoreSettings.cs
Expand Up @@ -108,6 +108,18 @@ public class DotNetRestoreSettings : DotNetSettings
/// </remarks>
public bool ForceEvaluate { get; set; }

/// <summary>
/// Gets or sets a value indicating whether to compile your application assemblies as ReadyToRun (R2R) format.
/// </summary>
/// <remarks>
/// In .NET 6, dotnet restore followed by dotnet publish -p:PublishReadyToRun=true --no-restore will fail with the NETSDK1095 error.
/// This is because the crossgen binary is now shipped as a separate NuGet package, and so needs to be part of the restore operation for publishing to succeed.
/// <para>
/// Supported by .NET SDK version 6.0.100 and above.
/// </para>
/// </remarks>
public bool? PublishReadyToRun { get; set; }

/// <summary>
/// Gets or sets additional arguments to be passed to MSBuild.
/// </summary>
Expand Down
15 changes: 14 additions & 1 deletion src/Cake.Common/Tools/DotNet/Restore/DotNetRestorer.cs
Expand Up @@ -148,12 +148,25 @@ private ProcessArgumentBuilder GetArguments(string root, DotNetRestoreSettings s
builder.AppendSwitchQuoted("--lock-file-path", " ", settings.LockFilePath.MakeAbsolute(_environment).FullPath);
}

// force evaluate
// Force Evaluate
if (settings.ForceEvaluate)
{
builder.Append("--force-evaluate");
}

// Publish ReadyToRun
if (settings.PublishReadyToRun.HasValue)
{
if (settings.PublishReadyToRun.Value)
{
builder.Append("-p:PublishReadyToRun=true");
}
else
{
builder.Append("-p:PublishReadyToRun=false");
}
}

if (settings.MSBuildSettings != null)
{
builder.AppendMSBuildSettings(settings.MSBuildSettings, _environment);
Expand Down

0 comments on commit 3861561

Please sign in to comment.