Your project does not reference ".NETFramework,Version=v4.5" framework. Add a reference to ".NETFramework,Version=v4.5"

Viewed 2617

Visual Studio Version: 2019 Summary: I have two framework projects in same folder, 4.7 framework project has local Nuget Package reference and 4.5 framework project has local Assembly reference. The reported issue occurs when run 4.5 project after run the 4.7 projects

Issue: Severity Code Description Project File Line Suppression State Error Your project does not reference ".NETFramework,Version=v4.5" framework. Add a reference to ".NETFramework,Version=v4.5" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.

4.7 Project

  <ItemGroup>
   <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
</ItemGroup>

4.5 Project

<Reference Include="Microsoft.Xaml.Behaviors.Wpf" xmlns="">
  <HintPath>..\resources\Assembilies\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference>

Steps to Reproduce:

  1. Run 4.7 project with nuget reference

  2. run 4.5 project with assembly reference

  3. will reproduce the reported issue

How to solve this issue

1 Answers

If anyone is ever stuck on a legacy project, the solution in the end was to delete the contents of bin and obj folders, and the .vs directory for the solution.

Related