Skip to content

Commit 9523479

Browse files
timcassellclaude
andcommitted
Skip building project references in no-dependencies publishes
dotnet publish accepts --no-dependencies but still builds project references, unlike dotnet build. Integration tests on .NET Core hosts therefore rebuilt the whole benchmark project graph for every publishing partition (NativeAOT, Mono, Wasm, R2R, CoreRun), including the running test project, whose locked output could fail the build when a referenced DLL went stale mid-run. Pass /p:BuildProjectReferences=false alongside --no-dependencies, and keep the generated build script in sync. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent 32c8cb6 commit 9523479

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎src/BenchmarkDotNet/Toolchains/CsProj/CsProjBuilder.cs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ private void AppendBuild(StringBuilder content, BuildPartition buildPartition, A
119119
/// </summary>
120120
private void AppendPublish(StringBuilder content, BuildPartition buildPartition, ArtifactsPaths artifactsPaths)
121121
=> AppendCall(content, buildPartition.ForcedNoDependenciesForIntegrationTests
122-
? DotNetCliCommand.GetPublishCommand(artifactsPaths, buildPartition, artifactsPaths.ProjectFilePath, Settings.TargetFrameworkMoniker, "--no-dependencies", "publish-no-deps")
122+
? DotNetCliCommand.GetPublishCommand(artifactsPaths, buildPartition, artifactsPaths.ProjectFilePath, Settings.TargetFrameworkMoniker, DotNetCliCommand.PublishNoDependenciesArguments, "publish-no-deps")
123123
: DotNetCliCommand.GetPublishCommand(artifactsPaths, buildPartition, artifactsPaths.ProjectFilePath, Settings.TargetFrameworkMoniker, null, "publish"));
124124

125125
private void AppendCall(StringBuilder content, string command)

‎src/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliCommand.cs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ namespace BenchmarkDotNet.Toolchains.DotNetCli
1212
{
1313
public class DotNetCliCommand
1414
{
15+
// For publish, --no-dependencies only keeps restore from following project references, so it still builds them.
16+
internal const string PublishNoDependenciesArguments = "--no-dependencies /p:BuildProjectReferences=false";
17+
1518
[PublicAPI] public FileInfo? CliPath { get; }
1619

1720
[PublicAPI] public string FilePath { get; }
@@ -127,7 +130,7 @@ public async Task<BuildResult> PublishAsync(CancellationToken cancellationToken
127130
// On our CI, Integration tests take too much time, because each benchmark run rebuilds BenchmarkDotNet itself.
128131
// To reduce the total duration of the CI workflows, we build all the projects without dependencies
129132
var result = await DotNetCliCommandExecutor.ExecuteAsync(
130-
WithArguments(GetPublishCommand(ArtifactsPaths, BuildPartition, FilePath, TargetFrameworkMoniker, $"{Arguments} --no-dependencies", "publish-no-deps")),
133+
WithArguments(GetPublishCommand(ArtifactsPaths, BuildPartition, FilePath, TargetFrameworkMoniker, $"{Arguments} {PublishNoDependenciesArguments}", "publish-no-deps")),
131134
cancellationToken).ConfigureAwait(false);
132135
return result.ToBuildResult(ArtifactsPaths);
133136
}

0 commit comments

Comments
 (0)