dotnet / dotnet/msbuild

Bad error message when referencing a non-SDK multitargeting project

Open
#10,629 0 comments 1 reaction 0 assignees View on GitHub
Area: Debuggability backlog Priority:3 triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

Given a .NET Framework project (non-SDK) referenced by any project, (erroneously) add

```xml
net46;net8.0
```

to try to make it multitarget. That is ignored by the non-SDK common targets, so the individual project can build, but the referencing project fails before RPR, leaving you with

```sh-session
> msbuild -bl
ClassLibrary2 succeeded (0.1s) → ClassLibrary2\bin\Debug\ClassLibrary2.dll
You are using a preview version of .NET. See: https://aka.ms/dotnet-support-policy
ClassLibrary2 failed with 1 error(s) (0.0s)
C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin\amd64\Microsoft.Common.CurrentVersion.targets(1967,5): error : Internal MSBuild error: Non-CrossTargeting GetTargetFrameworks target should not be used in cross targeting (outer) build

Build failed with 1 error(s) in 0.6s
```

That error isn't _wrong_ but it sure doesn't help you fix the problem.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.