When i tried to build a project that targeted to many frameworks include ".net 6.0" and / or netstandardX.X the visual studio 2017. The error on the subject occure even after installed .NET 6.0 that include:
- .NET Runtime 6.x.x
- ASP.NET Core Runtime 6.x.x
- .NET Desktop Runtime 6.x.x
(x depends on the release)
Also the dependencies on solution explorer shows an error (see screenshot)
the sdk i installed is compatible with the "global.json" file content:
{
"sdk": {
"version": "6.0.401",
"allowPrerelease": false,
"rollForward": "feature"
}
}
The entire error message :
Severity Code Description Project File Line Suppression State Error MSB3644 The reference assemblies for framework ".NETFramework,Version=v6.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
butthis message is also for all the missing or unrecognized dependencies.
.csproj file (target framework):
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.1;netstandard2.0;net45;net48;netstandard1.5;net40;net35;net20;net6.0</TargetFrameworks>
</PropertyGroup
<PropertyGroup Condition="'$(TargetFramework)' == 'net20' ">
<DefineConstants>$(DefineConstants);LEGACY</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net35' ">
<DefineConstants>$(DefineConstants);LEGACY</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net40' ">
<DefineConstants>$(DefineConstants);LEGACY</DefineConstants>
</PropertyGroup>
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.5' ">
<PackageReference Include="System.Collections.NonGeneric" Version="4.0.1" />
<PackageReference Include="System.Collections.Specialized" Version="4.0.1" />
<PackageReference Include="System.Reflection" Version="4.3.0" />
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.1.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net20" Version="1.0.3" Condition="'$(TargetFramework)' == 'net20' ">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net35" Version="1.0.3" Condition="'$(TargetFramework)' == 'net35' ">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net40" Version="1.0.3" Condition="'$(TargetFramework)' == 'net40' ">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net45" Version="1.0.3" Condition="'$(TargetFramework)' == 'net45' ">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies.net48" Version="1.0.3" Condition="'$(TargetFramework)' == 'net48' ">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>
Without any changes, and relying on this:
I installed Visual Studio 2022 and the project build succeeded.
The dependencies naming stays as it is in the question.
So the solution is to remove dependencies of .NET6.0 by deleting it from target framework on .csproj file, OR to install Visual Studio 2022.