Skip to content
Open
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
6 changes: 2 additions & 4 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
<ItemGroup>
<PackageVersion Include="Basic.CompilerLog.Util" Version="0.9.18" />
<PackageVersion Include="AwesomeAssertions" Version="$(AwesomeAssertionsVersion)" />
<PackageVersion Include="BenchmarkDotNet" Version="$(BenchmarkDotNetPackageVersion)" />
<PackageVersion Include="AwesomeAssertions.Json" Version="$(AwesomeAssertionsJsonVersion)" />
<PackageVersion Include="BenchmarkDotNet" Version="$(BenchmarkDotNetPackageVersion)" />
<PackageVersion Include="BenchmarkDotNet.Diagnostics.Windows" Version="$(BenchmarkDotNetDiagnosticsWindowsPackageVersion)" />
<PackageVersion Include="MessagePack" Version="3.1.4" />
<PackageVersion Include="MicroBuild.Plugins.SwixBuild.Dotnet" Version="1.1.87-gba258badda" />
<PackageVersion Include="Microsoft.ApplicationInsights" Version="$(MicrosoftApplicationInsightsPackageVersion)" />
Expand Down Expand Up @@ -38,13 +39,11 @@
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.Common" Version="$(MicrosoftCodeAnalysisPackageVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.Workspaces.MSBuild" Version="$(MicrosoftCodeAnalysisWorkspacesMSBuildPackageVersion)" />
<PackageVersion Include="Microsoft.CodeAnalysis.ExternalAccess.HotReload" Version="$(MicrosoftCodeAnalysisExternalAccessHotReloadPackageVersion)" />

<!-- roslyn-sdk dependencies-->
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeFix.Testing" Version="1.1.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp.CodeRefactoring.Testing" Version="1.1.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.CodeFix.Testing" Version="1.1.2" />
<PackageVersion Include="Microsoft.CodeAnalysis.VisualBasic.CodeRefactoring.Testing" Version="1.1.2" />

<PackageVersion Include="Microsoft.Css.Parser" Version="$(MicrosoftCssParserVersion)" />
<PackageVersion Include="Microsoft.DiaSymReader" Version="$(MicrosoftDiaSymReaderVersion)" />
<PackageVersion Include="Microsoft.Deployment.DotNet.Releases" Version="$(MicrosoftDeploymentDotNetReleasesVersion)" />
Expand Down Expand Up @@ -146,7 +145,6 @@
<PackageVersion Include="xunit.assert" Version="$(XUnitVersion)" Condition="'$(IsTestProject)' != 'true'" />
<PackageVersion Include="xunit.console" Version="$(XUnitVersion)" />
</ItemGroup>

<!-- Use different versions of Microsoft.Build.* depending on whether the output will be used in
.NET Framework (VS) or only in the .NET SDK.

Expand Down
7 changes: 6 additions & 1 deletion build/GenerateResxSource.targets
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

<PropertyGroup>
<CustomizeXlfSourceNamesDependsOn Condition="'$(SkipCustomizeXlfSourceNames)'!='true'">_CustomizeResourceNames</CustomizeXlfSourceNamesDependsOn>
</PropertyGroup>

<Target Name="_CustomizeXlfSourceNames"
DependsOnTargets="_CustomizeResourceNames"
DependsOnTargets="$(CustomizeXlfSourceNamesDependsOn)"
BeforeTargets="PrepareResourceNames;GatherXlf"
Condition="'$(SkipCustomizeXlfSourceNames)'!='true'"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You shouldn't need both this Condition and the change to the DependsOnTargets - if a Condition evaluates to false then the DependsOnTargets should not be run at all. Were you seeing different?

>
<ItemGroup>
<XlfSource Condition="'%(XlfSource.Namespace)' != ''">
Expand Down
3 changes: 2 additions & 1 deletion eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@
<MoqPackageVersion>4.18.4</MoqPackageVersion>
<XunitCombinatorialVersion>1.3.2</XunitCombinatorialVersion>
<MicrosoftDotNetInstallerWindowsSecurityTestDataPackageVersion>8.0.0-beta.23607.1</MicrosoftDotNetInstallerWindowsSecurityTestDataPackageVersion>
<BenchmarkDotNetPackageVersion>0.14.0</BenchmarkDotNetPackageVersion>
<BenchmarkDotNetPackageVersion>0.15.6</BenchmarkDotNetPackageVersion>
<BenchmarkDotNetDiagnosticsWindowsPackageVersion>0.14.0</BenchmarkDotNetDiagnosticsWindowsPackageVersion>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<BenchmarkDotNetDiagnosticsWindowsPackageVersion>0.14.0</BenchmarkDotNetDiagnosticsWindowsPackageVersion>
<BenchmarkDotNetDiagnosticsWindowsPackageVersion>0.15.6</BenchmarkDotNetDiagnosticsWindowsPackageVersion>

If these packages version together we may want to use a single property to ensure they don't drift.

</PropertyGroup>
<PropertyGroup Label="Workload manifest package versions">
<MauiFeatureBand>10.0.100</MauiFeatureBand>
Expand Down
1 change: 1 addition & 0 deletions sdk.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@
<Project Path="src/Tasks/Microsoft.NET.Build.Extensions.Tasks.UnitTests/Microsoft.NET.Build.Extensions.Tasks.UnitTests.csproj" />
<Project Path="test/ArgumentForwarding.Tests/ArgumentForwarding.Tests.csproj" />
<Project Path="test/ArgumentsReflector/ArgumentsReflector.csproj" />
<Project Path="test/Benchmark/Benchmark.csproj" />
<Project Path="test/containerize.UnitTests/containerize.UnitTests.csproj" />
<Project Path="test/dotnet-format.UnitTests/dotnet-format.UnitTests.csproj" />
<Project Path="test/dotnet-MsiInstallation.Tests/dotnet-MsiInstallation.Tests.csproj" />
Expand Down
30 changes: 30 additions & 0 deletions test/Benchmark/Benchmark.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>$(ToolsetTargetFramework)</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<ExcludeFromSourceOnlyBuild>true</ExcludeFromSourceOnlyBuild>
<CanRunTestAsTool>false</CanRunTestAsTool>
<IsTestProject>false</IsTestProject>
<IsUnitTestProject>false</IsUnitTestProject>
<IncludeTestUsings>false</IncludeTestUsings>
<NoWarn>$(NoWarn);CS8002</NoWarn>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BenchmarkDotNet" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Cli\dotnet\dotnet.csproj" />
</ItemGroup>

<ItemGroup>
<!-- Copy to output so BenchmarkDotNet generated projects inherit this as well -->
<None Include="Directory.Build.props" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
17 changes: 17 additions & 0 deletions test/Benchmark/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<Project>
<PropertyGroup>
<!--
We need to output to something other than the normal bin and obj folders to prevent picking up the global.json that
is being dropped there as that will break building the project that BenchmarkDotNet generates to run the benchmarks.
-->
<BaseOutputPath>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '..', '..', 'artifacts', '$(MSBuildProjectName)', 'bin'))</BaseOutputPath>
<BaseIntermediateOutputPath>$([MSBuild]::NormalizeDirectory('$(MSBuildThisFileDirectory)', '..', '..', 'artifacts', '$(MSBuildProjectName)', 'obj'))</BaseIntermediateOutputPath>
Comment on lines +7 to +8
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's an ambient property called ArtifactsRoot or similar that is in use in the repo that gives you the path to the artifacts dir - within that dir, maybe consider using a benchmarks subdirectory for the project-specific output paths to prevent cluttering the 'root' of the artifacts with project-specific folders.


<!--
Skipping here as we want the auto-generated projects to skip as well. The project file will copy this Directory.Build.props
to the output folder and the auto-generated projects will implicitly import it.
-->
<SkipCustomizeXlfSourceNames>true</SkipCustomizeXlfSourceNames>
</PropertyGroup>
<Import Project="$([MSBuild]::GetPathOfFileAbove('Directory.Build.props', '$(MSBuildThisFileDirectory)..'))"/>
</Project>
19 changes: 19 additions & 0 deletions test/Benchmark/InfoTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using BenchmarkDotNet.Attributes;

namespace Benchmark;

[MemoryDiagnoser]
[SimpleJob(launchCount: 1, warmupCount: 1, iterationCount: 1, invocationCount: 1)]
public class InfoTests
{
private static readonly string[] s_args = ["--info"];

[Benchmark]
public int RunInfoCommand()
{
return Microsoft.DotNet.Cli.Program.Main(s_args);
}
}
49 changes: 49 additions & 0 deletions test/Benchmark/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using BenchmarkDotNet.Running;

namespace Benchmark;

internal class Program
{
static void Main(string[] args)
{
BenchmarkRunner.Run(typeof(Program).Assembly);

// BenchmarkDotNet bakes a fair amount of assumptions into the way it generates
// projects for running its benchmarks. One of the key problems we run into is how
// it figures out the root of the repository. It walks up the directory structure
// to find the first folder with a `*.sln` or `*.slnx` or `global.json`. It then
// searches down from there to find the project file. In the SDK repo currently
// we have a `global.json` in the `artifacts/bin` folder- that prevents it from
// finding the project file.
//
// We work around this currently by redirecting the output to `artifacts/Benchmark`.
// One partially explored alternative was to derive the `CsProjGenerator` and customize
// its `GetProjectFilePath(Type benchmarkTarget, ILogger logger)`. There is a fair
// amount of logic there that needs reimplemented, and you have to create a custom
// toolchain something like this:
//
// public class CustomToolchain : Toolchain
// {
// public CustomToolchain(string? tfm = default) : base(
// "CustomToolchain",
// new CustomCsProjGenerator(
// targetFrameworkMoniker: tfm ?? GetCurrentTfm(),
// cliPath: null,
// packagesPath: null,
// runtimeFrameworkVersion: null),
// new DotNetCliBuilder(tfm ?? GetCurrentTfm()),
// new DotNetCliExecutor(customDotNetCliPath: null)) { }
// }
//
// Things still break with the `bin/global.json` with this. Pulling in and tweaking
// everything that is needed to get the temporary project to build successfully looks
// to be a potential whack-a-mole problem, so starting by rooting the output in a new
// folder in the `artifacts` directory that ensures the repo root's `global.json` is
// in "scope" so we don't have to modify the toolchain.
//
// https://github.com/dotnet/BenchmarkDotNet/blob/master/src/BenchmarkDotNet/Toolchains/CsProj/CsProjGenerator.cs
}
}
2 changes: 1 addition & 1 deletion test/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<!-- Global usings -->
<!-- See: https://learn.microsoft.com/dotnet/core/project-sdk/msbuild-props#using -->
<ItemGroup>
<ItemGroup Condition="'$(IncludeTestUsings)'!='false'">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's worth having a top-level benchmarks directory in the repo root instead of putting it under test - our test structures pull in so much extra stuff that I would expect it to be hard to reason about, and having a separate folder lets your Dir.Build.props/targets anything specific to benchmarks alone really easily.

<Using Include="FluentAssertions" />
<Using Include="Microsoft.NET.TestFramework" />
<Using Include="Microsoft.NET.TestFramework.Assertions" />
Expand Down
Loading