I have a traversal that is responsible for build and publishing of projects. As such, any references to multi-targeting projects must be referenced with the TargetFramework global property explicitly set, to avoid a build error like this:
C:\Users\User\agent_work_tool\dotnet\sdk\8.0.402\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.CrossTargeting.targets(31,5): error NETSDK1129: The 'Publish' target is not supported without specifying a target framework. The current project targets multiple frameworks, you must specify one of the following frameworks in order to publish: net8.0, net8.0-windows10.0.22621.0, net8.0-macOS [C:\Users\User\agent_work\1\s\src\Nerdbank.Zcash.App\Nerdbank.Zcash.App.Desktop\Nerdbank.Zcash.App.Desktop.csproj]
So I set the typical ProjectReference metadata to target just the TargetFramework appropriate for the build agent:
I have a traversal that is responsible for build and publishing of projects. As such, any references to multi-targeting projects must be referenced with the
TargetFramework
global property explicitly set, to avoid a build error like this:So I set the typical
ProjectReference
metadata to target just the TargetFramework appropriate for the build agent:But this was totally ignored, and the project built without
TargetFramework
set, and it failed on Publish.