Skip to content

Update MsBuildErrorMapper #2503

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 14, 2024
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 @@ -69,6 +69,8 @@ private static string Map(Capture capture)
return "net472";
case ".NETFramework,Version=v4.8":
return "net48";
case ".NETFramework,Version=v4.8.1":
return "net481";
case ".NETCoreApp,Version=v2.0":
return "netcoreapp2.0";
case ".NETCoreApp,Version=v2.1":
Expand All @@ -83,6 +85,12 @@ private static string Map(Capture capture)
return "net5.0";
case ".NETCoreApp,Version=v6.0":
return "net6.0";
case ".NETCoreApp,Version=v7.0":
return "net7.0";
case ".NETCoreApp,Version=v8.0":
return "net8.0";
case ".NETCoreApp,Version=v9.0":
return "net9.0";
default:
return capture.Value; // we don't want to throw for future versions of .NET
}
Expand Down
14 changes: 7 additions & 7 deletions tests/BenchmarkDotNet.Tests/BuildResultTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,32 @@ public class BuildResultTests
[Fact]
public void NotFullyCompatibleMsBuildErrorIsTranslatedToMoreUserFriendlyVersion()
{
const string msbuildError = @"C:\Program Files\dotnet\sdk\3.0.100-preview9-013617\Microsoft.Common.CurrentVersion.targets(1653,5): warning NU1702: ProjectReference 'C:\Projects\BenchmarkDotNet\tests\BenchmarkDotNet.IntegrationTests.SingleRuntime.DotNetFramework\BenchmarkDotNet.IntegrationTests.SingleRuntime.DotNetFramework.csproj' was resolved using '.NETFramework,Version=v4.6.2' instead of the project target framework '.NETCoreApp,Version=v2.1'. This project may not be fully compatible with your project. [C:\Projects\BenchmarkDotNet\tests\BenchmarkDotNet.IntegrationTests\bin\Release\net462\Job-VUALUD\BenchmarkDotNet.Autogenerated.csproj]";
const string msbuildError = @"C:\Program Files\dotnet\sdk\3.0.100-preview9-013617\Microsoft.Common.CurrentVersion.targets(1653,5): warning NU1702: ProjectReference 'C:\Projects\BenchmarkDotNet\tests\BenchmarkDotNet.IntegrationTests.SingleRuntime.DotNetFramework\BenchmarkDotNet.IntegrationTests.SingleRuntime.DotNetFramework.csproj' was resolved using '.NETFramework,Version=v4.6.2' instead of the project target framework '.NETCoreApp,Version=v8.0'. This project may not be fully compatible with your project. [C:\Projects\BenchmarkDotNet\tests\BenchmarkDotNet.IntegrationTests\bin\Release\net462\Job-VUALUD\BenchmarkDotNet.Autogenerated.csproj]";

string expected = $@"The project which defines benchmarks does not target 'netcoreapp2.1'." + Environment.NewLine +
$"You need to add 'netcoreapp2.1' to <TargetFrameworks> in your project file " +
string expected = $@"The project which defines benchmarks does not target 'net8.0'." + Environment.NewLine +
$"You need to add 'net8.0' to <TargetFrameworks> in your project file " +
@"('C:\Projects\BenchmarkDotNet\tests\BenchmarkDotNet.IntegrationTests.SingleRuntime.DotNetFramework\BenchmarkDotNet.IntegrationTests.SingleRuntime.DotNetFramework.csproj')." + Environment.NewLine +
"Example: <TargetFrameworks>net462;netcoreapp2.1</TargetFrameworks>";
"Example: <TargetFrameworks>net462;net8.0</TargetFrameworks>";
Verify(msbuildError, true, expected);
}

[Fact]
public void NotCompatibleMsBuildErrorIsTranslatedToMoreUserFriendlyVersion()
{
const string msbuildError = @"error NU1201: Project BenchmarkDotNet.IntegrationTests.SingleRuntime.DotNetCore is not compatible with net462 (.NETFramework,Version=v4.6.2) / win7-x64. Project BenchmarkDotNet.IntegrationTests.SingleRuntime.DotNetCore supports: netcoreapp2.1 (.NETCoreApp,Version=v2.1)";
const string msbuildError = @"error NU1201: Project BenchmarkDotNet.IntegrationTests.SingleRuntime.DotNetCore is not compatible with net462 (.NETFramework,Version=v4.6.2) / win7-x64. Project BenchmarkDotNet.IntegrationTests.SingleRuntime.DotNetCore supports: net8.0 (.NETCoreApp,Version=v8.0)";

string expected = $@"The project which defines benchmarks does not target 'net462'." + Environment.NewLine +
$"You need to add 'net462' to <TargetFrameworks> in your project file " +
@"('BenchmarkDotNet.IntegrationTests.SingleRuntime.DotNetCore')." + Environment.NewLine +
"Example: <TargetFrameworks>netcoreapp2.1;net462</TargetFrameworks>";
"Example: <TargetFrameworks>net8.0;net462</TargetFrameworks>";

Verify(msbuildError, true, expected);
}

[Fact]
public void MissingSdkIsTranslatedToMoreUserFriendlyVersion()
{
const string msbuildError = @"C:\Program Files\dotnet\sdk\3.0.100-preview9-013617\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(134,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 5.0. Either target .NET Core 3.0 or lower, or use a version of the .NET SDK that supports .NET Core 5.0. [C:\Projects\BenchmarkDotNet\samples\BenchmarkDotNet.Samples\bin\Release\netcoreapp2.1\bad57fca-694a-41ad-b630-9e5317a782ab\BenchmarkDotNet.Autogenerated.csproj]";
const string msbuildError = @"C:\Program Files\dotnet\sdk\3.0.100-preview9-013617\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(134,5): error NETSDK1045: The current .NET SDK does not support targeting .NET Core 5.0. Either target .NET Core 3.0 or lower, or use a version of the .NET SDK that supports .NET Core 5.0. [C:\Projects\BenchmarkDotNet\samples\BenchmarkDotNet.Samples\bin\Release\net8.0\bad57fca-694a-41ad-b630-9e5317a782ab\BenchmarkDotNet.Autogenerated.csproj]";

string expected = "The current .NET SDK does not support targeting .NET Core 5.0. You need to install it or pass the path to dotnet cli via the `--cli` console line argument.";

Expand Down