NuGet Product Used
dotnet.exe
Product Version
.NET SDK: Version: 9.0.300
Worked before?
No response
Impact
None
Repro Steps & Context
When running dotnet list package on a solution(or project) that contains a multi-targeted SDK-style project with conditional elements(conditioned on the TFM), the CLI fails to resolve the Windows-specific target framework (net9.0-windows).
- Create an SDK-style project file (.csproj) with multi-targeting and conditional references:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net9.0;net9.0-windows</TargetFrameworks>
</PropertyGroup>
<ItemGroup Condition="'$(TargetFramework)'=='net9.0-windows'">
<PackageReference Include="MyProj.Base.Wpf" Version="1.0.0.0" />
<PackageReference Include="runtime_cpp" Version="1.0.0.0" />
<ProjectReference Include="..\MyProj.Output.Wpf\MyProj.Output.Wpf.csproj" />
</ItemGroup>
</Project>
- Run for sln or csproj:
dotnet restore MyProj.sln
dotnet list MyProj.sln package
- Error:
Unable to read a package reference from the project `D:\sources\repos\proj\src\MyProj.Web.API\MyProj.Web.API.csproj`.
Please make sure that your project file and project.assets.json file are in sync by running restore.
This works correctly if the condition is changed to match the full framework moniker (e.g. Condition="'$(TargetFramework)'=='net9.0-windows7.0'"), which suggests that dotnet list package is not properly resolving the shortened net9.0-windows TFM.
Originally reported here: dotnet/sdk#49179
Verbose Logs
adding `-v diag` does not produce any logs to this case
NuGet Product Used
dotnet.exe
Product Version
.NET SDK: Version: 9.0.300
Worked before?
No response
Impact
None
Repro Steps & Context
When running dotnet list package on a solution(or project) that contains a multi-targeted SDK-style project with conditional elements(conditioned on the TFM), the CLI fails to resolve the Windows-specific target framework (net9.0-windows).
This works correctly if the condition is changed to match the full framework moniker (e.g. Condition="'$(TargetFramework)'=='net9.0-windows7.0'"), which suggests that dotnet list package is not properly resolving the shortened net9.0-windows TFM.
Originally reported here: dotnet/sdk#49179
Verbose Logs