Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NuGet Restore is inconsistent about raising NU1201 #13777

Open
namerril opened this issue Sep 10, 2024 · 0 comments
Open

NuGet Restore is inconsistent about raising NU1201 #13777

namerril opened this issue Sep 10, 2024 · 0 comments

Comments

@namerril
Copy link

namerril commented Sep 10, 2024

NuGet Product Used

MSBuild.exe

Product Version

MSBuild 17.10.4.21802

Worked before?

No response

Impact

It's more difficult to complete my work

Repro Steps & Context

Justification: I'm attempting to build a package that depends on several different tools packages. These tools packages are built in the same repo and produce a package that is target framework independent. They are not dotnet tools.

For simplicity, I have the following projects:

Parent.csproj:

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <IncludeBuildOutput>false</IncludeBuildOutput>
    <PackageId>Parent.Package</PackageId>
    <NoWarn>NU5128</NoWarn>
  </PropertyGroup>

  <ItemGroup>
    <ProjectReference Include="..\Child1\Child1.csproj" ReferenceOutputAssembly="true" />
    <ProjectReference Include="..\Child2\Child2.csproj" ReferenceOutputAssembly="true" />
  </ItemGroup>
</Project>

Both Child.csproj projects look like the following:

  <PropertyGroup>
    <TargetFramework>net472</TargetFramework>
    <OutputType>Exe</OutputType>
    <AssemblyName>Child1</AssemblyName>
    <PlatformTarget>AnyCPU</PlatformTarget>
    <GeneratePackageOnBuild>true</GeneratePackageOnBuild>
    <IncludeBuildOutput>false</IncludeBuildOutput>
    <NoWarn>NU5128</NoWarn>
  </PropertyGroup>
  
  <ItemGroup>
    <None Include="$(OutputPath)\$(AssemblyName).exe" PackagePath="tools" Pack="true" />
  </ItemGroup>
</Project>

EXCEPT Child2.csproj targets net6.0 instead of net472.

The net6.0 target framework causes the following error: error NU1201: Project Child2 is not compatible with netstandard2.0 (.NETStandard,Version=v2.0). Project Child2 supports: net6.0 (.NETCoreApp,Version=v6.0). If I remove the dependency to Child2, I get a package with the dependency to Child1 in the netstandard2.0 target framework, as expected.

This is confusing to me. Netstandard2.0 is not compatible with BOTH net6.0 and net472. However, only net6.0 throws the error?

My real goal is to add the project references as a dependency to the NuGet, ignoring the target framework being used to build the tools DLL. Is this possible?

Verbose Logs

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant