Skip to content

Commit e20dd82

Browse files
committed
Pass PublishDir property to dotnet.
1 parent abd3720 commit e20dd82

File tree

8 files changed

+21
-6
lines changed

8 files changed

+21
-6
lines changed

Diff for: src/BenchmarkDotNet/Templates/MonoAOTLLVMCsProj.txt

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
<PropertyGroup>
1111
<OutputType>Exe</OutputType>
12-
<OutputPath>bin</OutputPath>
1312
<TargetFramework>$TFM$</TargetFramework>
1413
<MicrosoftNetCoreAppRuntimePackDir>$RUNTIMEPACK$</MicrosoftNetCoreAppRuntimePackDir>
1514
<RuntimeIdentifier>$RUNTIMEIDENTIFIER$</RuntimeIdentifier>

Diff for: src/BenchmarkDotNet/Templates/WasmCsProj.txt

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@
1111

1212
<PropertyGroup>
1313
<OutputType>Exe</OutputType>
14-
<OutputPath>bin</OutputPath>
1514
<RuntimeConfig>Release</RuntimeConfig>
1615
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
1716
<TargetFramework>$TFM$</TargetFramework>
1817
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
19-
<AppDir>$(MSBuildThisFileDirectory)\bin\$TFM$\browser-wasm\publish</AppDir>
18+
<AppDir>$(PublishDir)</AppDir>
2019
<AssemblyName>$PROGRAMNAME$</AssemblyName>
2120
<RuntimeIdentifier>browser-wasm</RuntimeIdentifier>
2221
<SuppressTrimAnalysisWarnings>true</SuppressTrimAnalysisWarnings>
@@ -49,8 +48,8 @@
4948

5049
<Target Name="PrepareForWasmBuild" AfterTargets="Publish">
5150
<ItemGroup>
52-
<WasmAssembliesToBundle Include="$(TargetDir)publish\*.dll" Condition="'$(RunAOTCompilation)' != 'true'" />
53-
<WasmAssembliesToBundle Include="$(TargetDir)publish\*.dll" Exclude="$(TargetDir)publish\KernelTraceControl.dll" Condition="'$(RunAOTCompilation)' == 'true'" />
51+
<WasmAssembliesToBundle Include="$(PublishDir)*.dll" Condition="'$(RunAOTCompilation)' != 'true'" />
52+
<WasmAssembliesToBundle Include="$(PublishDir)*.dll" Exclude="$(PublishDir)KernelTraceControl.dll" Condition="'$(RunAOTCompilation)' == 'true'" />
5453
</ItemGroup>
5554
</Target>
5655

Diff for: src/BenchmarkDotNet/Toolchains/ArtifactsPaths.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ namespace BenchmarkDotNet.Toolchains
44
{
55
public class ArtifactsPaths
66
{
7-
public static readonly ArtifactsPaths Empty = new ArtifactsPaths("", "", "", "", "", "", "", "", "", "", "", "");
7+
public static readonly ArtifactsPaths Empty = new ArtifactsPaths("", "", "", "", "", "", "", "", "", "", "", "", "");
88

99
[PublicAPI] public string RootArtifactsFolderPath { get; }
1010
[PublicAPI] public string BuildArtifactsDirectoryPath { get; }
11+
[PublicAPI] public string PublishDirectoryPath { get; }
1112
[PublicAPI] public string BinariesDirectoryPath { get; }
1213
[PublicAPI] public string IntermediateDirectoryPath { get; }
1314
[PublicAPI] public string ProgramCodePath { get; }
@@ -22,6 +23,7 @@ public class ArtifactsPaths
2223
public ArtifactsPaths(
2324
string rootArtifactsFolderPath,
2425
string buildArtifactsDirectoryPath,
26+
string publishDirectoryPath,
2527
string binariesDirectoryPath,
2628
string intermediateDirectoryPath,
2729
string programCodePath,
@@ -35,6 +37,7 @@ public ArtifactsPaths(
3537
{
3638
RootArtifactsFolderPath = rootArtifactsFolderPath;
3739
BuildArtifactsDirectoryPath = buildArtifactsDirectoryPath;
40+
PublishDirectoryPath = publishDirectoryPath;
3841
BinariesDirectoryPath = binariesDirectoryPath;
3942
IntermediateDirectoryPath = intermediateDirectoryPath;
4043
ProgramCodePath = programCodePath;

Diff for: src/BenchmarkDotNet/Toolchains/DotNetCli/DotNetCliCommand.cs

+1
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ internal static StringBuilder MaybeAppendOutputPaths(this StringBuilder stringBu
281281
.AppendArgument($"/p:OutDir=\"{artifactsPaths.BinariesDirectoryPath}{Path.AltDirectorySeparatorChar}\"")
282282
// OutputPath is legacy, per-project version of OutDir. We set both just in case. https://github.com/dotnet/msbuild/issues/87
283283
.AppendArgument($"/p:OutputPath=\"{artifactsPaths.BinariesDirectoryPath}{Path.AltDirectorySeparatorChar}\"")
284+
.AppendArgument($"/p:PublishDir=\"{artifactsPaths.PublishDirectoryPath}{Path.AltDirectorySeparatorChar}\"")
284285
.AppendArgument(isRestore ? string.Empty : $"--output \"{artifactsPaths.BinariesDirectoryPath}{Path.AltDirectorySeparatorChar}\"")
285286
;
286287
}

Diff for: src/BenchmarkDotNet/Toolchains/GeneratorBase.cs

+8
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ public GenerateResult GenerateProject(BuildPartition buildPartition, ILogger log
4444
/// </summary>
4545
[PublicAPI] protected abstract string GetBuildArtifactsDirectoryPath(BuildPartition assemblyLocation, string programName);
4646

47+
/// <summary>
48+
/// returns a path where the publish directory should be found after the build (usually \publish)
49+
/// </summary>
50+
[PublicAPI]
51+
protected virtual string GetPublishDirectoryPath(string buildArtifactsDirectoryPath, string configuration)
52+
=> Path.Combine(buildArtifactsDirectoryPath, "publish");
53+
4754
/// <summary>
4855
/// returns a path where executable should be found after the build (usually \bin)
4956
/// </summary>
@@ -137,6 +144,7 @@ private ArtifactsPaths GetArtifactsPaths(BuildPartition buildPartition, string r
137144
return new ArtifactsPaths(
138145
rootArtifactsFolderPath: rootArtifactsFolderPath,
139146
buildArtifactsDirectoryPath: buildArtifactsDirectoryPath,
147+
publishDirectoryPath: GetPublishDirectoryPath(buildArtifactsDirectoryPath, buildPartition.BuildConfiguration),
140148
binariesDirectoryPath: binariesDirectoryPath,
141149
intermediateDirectoryPath: GetIntermediateDirectoryPath(buildArtifactsDirectoryPath, buildPartition.BuildConfiguration),
142150
programCodePath: Path.Combine(buildArtifactsDirectoryPath, $"{programName}{codeFileExtension}"),

Diff for: src/BenchmarkDotNet/Toolchains/InProcess/Emit/InProcessEmitArtifactsPath.cs

+1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public InProcessEmitArtifactsPath(
1111
ArtifactsPaths baseArtifacts) : base(
1212
baseArtifacts.RootArtifactsFolderPath,
1313
baseArtifacts.BuildArtifactsDirectoryPath,
14+
baseArtifacts.PublishDirectoryPath,
1415
baseArtifacts.BinariesDirectoryPath,
1516
baseArtifacts.IntermediateDirectoryPath,
1617
baseArtifacts.ProgramCodePath,

Diff for: src/BenchmarkDotNet/Toolchains/InProcess/Emit/InProcessEmitGenerator.cs

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ private ArtifactsPaths GetArtifactsPaths(BuildPartition buildPartition, string r
4646
return new ArtifactsPaths(
4747
rootArtifactsFolderPath: rootArtifactsFolderPath,
4848
buildArtifactsDirectoryPath: buildArtifactsDirectoryPath,
49+
publishDirectoryPath: null,
4950
binariesDirectoryPath: binariesDirectoryPath,
5051
intermediateDirectoryPath: null,
5152
programCodePath: null,

Diff for: src/BenchmarkDotNet/Toolchains/MonoAotLLVM/MonoAotLLVMGenerator.cs

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ protected override void GenerateProject(BuildPartition buildPartition, Artifacts
5454
File.WriteAllText(artifactsPaths.ProjectFilePath, content);
5555
}
5656

57+
protected override string GetPublishDirectoryPath(string buildArtifactsDirectoryPath, string configuration)
58+
=> Path.Combine(GetBinariesDirectoryPath(buildArtifactsDirectoryPath, configuration), "publish");
59+
5760
protected override string GetExecutablePath(string binariesDirectoryPath, string programName)
5861
=> OsDetector.IsWindows()
5962
? Path.Combine(binariesDirectoryPath, "publish", $"{programName}.exe")

0 commit comments

Comments
 (0)