##[error]C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(1217,5): Error MSB3644: The reference assemblies for .NETFramework,Version=v4.5 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at...

- 1,621
- 4
- 17
- 16
-
Have tried installing .NET Framework version 4.5, 4.8, 5.0 and even 6.0 but the same error is displayed every time – Debashisenator Nov 25 '21 at 05:02
-
any solution you got? – Kiran Solkar Mar 30 '23 at 09:46
4 Answers
my solution was to upgrade any project targeting .Net Framework 4.5 to 4.7.2 and then building on Visual Studio 2019 instead of 2022, same Win Server 2019

- 147
- 4
- 14
-
this worked for me too, running windows server 2022 and installed vs build tools 2019 – Phil Apr 20 '22 at 15:09
Changing from
vmImage: 'windows-latest'
to
vmImage: 'windows-2019'
worked for me. It used to work earlier because 2019 was latest, now the latest is 2022 and there is issue with that.

- 2,495
- 2
- 20
- 29
I am also having this issue. Here is my (unsuccessful) progress in trying to solve it
I am also having this issue in Visual Studio 2022 Community after switching all of my solution's projects from various versions of .NET Framework to now all targeting ".NET Framework 4.8".
My error (almost identical to OP's):
C:\Program Files\dotnet\sdk\6.0.101\Microsoft.Common.CurrentVersion.targets(1217,5): error MSB3644: The reference assemblies for .NETFramework,Version=v2.0 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks [C:\Users\MyUsername\source\repos\MyRepo1\Source\Libs\MyLibs\MyLibProject\MyLibProject.csproj]
This error mentions column 5 of line 1217 of file C:\Program Files\dotnet\sdk\6.0.101\Microsoft.Common.CurrentVersion.targets
, this leads to the part <GetReferenceAssemblyPaths
of the following:
<Target
Name="GetReferenceAssemblyPaths"
DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn);GetFrameworkPaths">
...
<!-- By default if there is no root path set then the task will assume it is Program Files\Reference Assemblies\Microsoft\Framework-->
<GetReferenceAssemblyPaths
Condition="'$(TargetFrameworkMoniker)' != '' and ('$(_TargetFrameworkDirectories)' == '' or '$(_FullFrameworkReferenceAssemblyPaths)' == '')"
TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
RootPath="$(TargetFrameworkRootPath)"
TargetFrameworkFallbackSearchPaths="$(TargetFrameworkFallbackSearchPaths)"
BypassFrameworkInstallChecks="$(BypassFrameworkInstallChecks)"
>
<Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
<Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName" Condition="'$(TargetFrameworkMonikerDisplayName)' == ''"/>
</GetReferenceAssemblyPaths>
...
</Target>
I understand that the parts like $(TargetFrameworkMoniker)
are variables. To determine what these evaluate to, I go into Visual Studio, open the csproj file, go to "Build Events > Pre-build event command line" and type echo "TargetFrameworkMoniker" = "$(TargetFrameworkMoniker)"
. Then I save & build the project, ignore the errors and instead go to the window "Output" to see what these variable evaluate to. I do this for each of the variables. Below is the same code from above, but the variables are now what they actually evaluate to (for me):
<Target
Name="GetReferenceAssemblyPaths"
DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn);GetFrameworkPaths">
...
<!-- By default if there is no root path set then the task will assume it is Program Files\Reference Assemblies\Microsoft\Framework-->
<GetReferenceAssemblyPaths
Condition="'.NETFramework,Version=v4.8' != '' and ('' == '' or '' == '')"
TargetFrameworkMoniker=".NETFramework,Version=v4.8"
RootPath=""
TargetFrameworkFallbackSearchPaths=""
BypassFrameworkInstallChecks=""
>
<Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
<Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
<Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName" Condition="'' == ''"/>
</GetReferenceAssemblyPaths>
...
</Target>
I don't see anything that suggests anything other than ".NET Framework 4.8", so I am now unsure how to proceed.

- 13
- 3
I got this issue resolved by downgrading from Visual Studio 2022 to Visual Studio 2014. I uninstalled Visual Studio 2022 and installed Visual Studio 2014, and the rest fell in place. My installation is now up and running.

- 1,621
- 4
- 17
- 16