17

I have installed Visual Studio 2022 on my PC today. I have an old app, which targets .NET 4.5. I see this error when attempting to build/compile the project:

"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 https://aka.ms/msbuild/developerpacks"

I have read this: https://thomaslevesque.com/2021/11/12/building-a-project-that-target-net-45-in-visual-studio-2022/. C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5 already exists on my PC.

I have downloaded the .NET 4.5 Developer Pack here: https://learn.microsoft.com/en-gb/dotnet/framework/install/guide-for-developers. I see this when I attempt to run it:

enter image description here

Is there anything else I can try?

D-Shih
  • 44,943
  • 6
  • 31
  • 51
w0051977
  • 15,099
  • 32
  • 152
  • 329

2 Answers2

38

Because you might install a higher version of .net framework firstly, so installer might stop you install a lower version of .net framework

There is another way can try to fix it without reinstalling.

  1. Download Microsoft.NETFramework.ReferenceAssemblies.net45 package file enter image description here
  2. Modify the file extension name from microsoft.netframework.referenceassemblies.net45.nupkg to microsoft.netframework.referenceassemblies.net45.zip and Unzip that
  3. Copy the files from build\.NETFramework\v4.5\ to C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5
  4. Running your project again.

Note

This way was also work for .net4.0 Microsoft.NETFramework.ReferenceAssemblies.net40 or other older version of .net framework which Microsoft might not support in feature

D-Shih
  • 44,943
  • 6
  • 31
  • 51
  • 3
    Thanks. That did the trick. +1 for the step by step instructions. – w0051977 Apr 20 '22 at 16:31
  • 1
    I wish I could give you a 100 upvotes, if I could.. this solved my problem which I thought was only occurring on my machine as I was new to the project.. and a latest pull somehow screwed it up and its now several hours that I searched and finally reached here.. Thank u very much – Irf Jul 22 '22 at 11:23
  • 1
    I also used this method for .net 3.5. Works! – Rots Sep 27 '22 at 21:48
  • 1
    I did the trick, upvote+. thanks – VnDevil Nov 07 '22 at 05:38
2

If you want a less hacky way, another option is to download the VS2017 Build Tools and install the .NET Framework 4.5 Targeting Pack only (from the tab Individual Components). This works fine with Visual Studio 2022, since it installs the reference assemblies where they are needed.

enter image description here

Brent Thierens
  • 371
  • 2
  • 12