Skip to content

Breaks GeneratePackageOnBuild when targetting multiple frameworks #1221

@xtu-ranplan

Description

@xtu-ranplan

In a VS solution with two projects:

Project Target Framework GeneratePackageOnBuild
ClassLibrary1 <TargetFramework>netstandard2.0</TargetFramework> true
test-GeneratePackageOnBuild <TargetFrameworks>net8.0;net472</TargetFrameworks> true

When project ClassLibrary1 has a package reference to NerdBank.GitVersioning, the build fails in Visual Studio with this error:

2>Target _GetProjectReferenceVersions:
2>  Target InvokeGetBuildVersionTask:
2>    Target GetBuildVersionCore:
2>      Building version 1.0 from commit
2>  Target _CheckForUnsupportedTargetFramework:
2>    C:\Program Files\dotnet\sdk\9.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(96,5): error NETSDK1013: The TargetFramework value '' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly.
2>  Done building target "_CheckForUnsupportedTargetFramework" in project "ClassLibrary1.csproj" -- FAILED.
2>
2>  Done building project "ClassLibrary1.csproj" -- FAILED.
2>
2>Build FAILED.
2>
2>C:\Program Files\dotnet\sdk\9.0.301\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.TargetFrameworkInference.targets(96,5): error NETSDK1013: The TargetFramework value '' was not recognized. It may be misspelled. If not, then the TargetFrameworkIdentifier and/or TargetFrameworkVersion properties must be specified explicitly.
2>    0 Warning(s)
2>    1 Error(s)
2>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions