dotnet / docfx

Static site generator for .NET API documentation.
https://dotnet.github.io/docfx/
MIT License
4.06k stars 864 forks source link

[Bug] NETSDK1045 error annotations are reported on CI build. #8928

Closed filzrev closed 11 months ago

filzrev commented 1 year ago

Describe the bug

GitHub actions reports following annotation errors when ci.yml executed.

https://github.com/dotnet/docfx/actions/runs/5441955687

test (ubuntu-latest) The current .NET SDK does not support targeting .NET 7.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 7.0.

These annotations are generated by problem-matcher. And these errors are picked from dotnet test logs.

To Reproduce Problem It can reproduce problems with following steps on local ubuntu environment.

  1. cd to docfx/test/docfx.Tests
  2. Execute dotnet restore -p:TargetFramework=net6.0
  3. Execute dotnet test --framework:net6.0 --no-build

if Solution Directory.Build.props file's TargetFrameworks is modified from net7.0;net6.0 to net6.0. These error is disappeared.

Root cause of this errors docfx.Test project create temporary .csproj targeting .net6.0 under bin directory. But there is Directory.Build.props at solution root level. and target frameworks (net6.0/net7.0) are specified. So, Directory.Build.props settings are applied these .csproj.

It might be better to create temp working directory to OS's temp directory.

Additional context

On ubuntu environments. CI Build succeeded. But some extra warnings are reported on log.

warning: [Failure] Project file not found: '/home/runner/work/docfx/docfx/test/docfx.Tests/bin/Release/net6.0/1jc3olh4.spy/ref.csproj'

filzrev commented 11 months ago

This issue is resolved by following commit. https://github.com/dotnet/docfx/pull/9424#issuecomment-1811585154