sdk
sdk copied to clipboard
dotnet msbuild -t:restore or -t:publish : NU1201: Not compatible with netcoreapp2.2
Steps to reproduce
I try to restore and publish a cross-targeting and cross-platform project with netcoreapp/netstandard/net472 and linux-x64/win-x64 mix-match with:
# Restoring:
dotnet msbuild -t:restore -p:targetframework=net472 -p:runtimeidentifier=win-x64 Api.csproj
# OR
dotnet msbuild -t:restore -p:targetframework=netcoreapp2.2 -p:runtimeidentifier=linux-x64 Api.csproj
# AND publishing:
dotnet msbuild -t:publish -p:targetframework=net472 -p:runtimeidentifier=win-x64 Api.csproj
# OR
dotnet msbuild -t:publish -p:targetframework=netcoreapp2.2 -p:runtimeidentifier=linux-x64 Api.csproj
The projects
Api.csproj
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFrameworks>netcoreapp2.2;net472</TargetFrameworks>
<RuntimeIdentifiers>linux-x64;win-x64</RuntimeIdentifiers>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="Core.csproj" />
<ProjectReference Include="Store.csproj" />
</ItemGroup>
</Project>
Core.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
</Project>
Store.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="Core.csproj" />
</ItemGroup>
</Project>
Sdk.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;net472</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="Core.csproj" />
</ItemGroup>
</Project>
Cli.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="Sdk.csproj" />
</ItemGroup>
</Project>
Expected behavior
The projects should be restored for all TFM's and RID's.
Actual behavior
The following error is thrown:
D:\projects\_lab\dotnet-sdk-issues\msbuild-restore\Api.csproj : error NU1201: Project Core is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Project Core supports: net472 (.NETFramework,Version=v4.7.2)
D:\projects\_lab\dotnet-sdk-issues\msbuild-restore\Api.csproj : error NU1201: Project Store is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2). Project Store supports: net472 (.NETFramework,Version=v4.7.2)
D:\projects\_lab\dotnet-sdk-issues\msbuild-restore\Api.csproj : error NU1201: Project Core is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2) / linux-x64. Project Core supports: net472 (.NETFramework,Version=v4.7.2)
D:\projects\_lab\dotnet-sdk-issues\msbuild-restore\Api.csproj : error NU1201: Project Store is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2) / linux-x64. Project Store supports: net472 (.NETFramework,Version=v4.7.2)
D:\projects\_lab\dotnet-sdk-issues\msbuild-restore\Api.csproj : error NU1201: Project Core is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2) / win-x64. Project Core supports: net472 (.NETFramework,Version=v4.7.2)
D:\projects\_lab\dotnet-sdk-issues\msbuild-restore\Api.csproj : error NU1201: Project Store is not compatible with netcoreapp2.2 (.NETCoreApp,Version=v2.2) / win-x64. Project Store supports: net472 (.NETFramework,Version=v4.7.2)
looks like an instance of https://github.com/NuGet/Home/issues/7286 cc @nkolev92
@dasMulli thanks for the hint! And what should or can we do in this situation?
@DoCode sorry for the delay. don't pass the TargetFramework to the restore. When using dotnet publish et al. which do an implicit restore, they apply logic to filter out a TFM argument to avoid this..
https://github.com/dotnet/cli/blob/9e8a03aec2dea6d99cb499eea04fd1252e6ab242/src/dotnet/commands/RestoringCommand.cs#L72-L73
Due to lack of recent activity, this issue has been labeled as 'stale'. It will be closed if no further activity occurs within 30 more days. Any new comment will remove the label.
This issue will now be closed since it has been labeled 'stale' without activity for 30 days.