Skip to content
Merged
Show file tree
Hide file tree
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
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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