Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MSB3644 The reference assemblies for framework were not found

I am getting the following MSB3644 complication error:

The reference assemblies for framework ".NETFramework,Version=v4.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.

From what I've read here, it is due to assemblies on my machine stored in "Program Files" and not in "Program Files (x86)". A FrameworkPathOverride property on MSBuild can fix it.

I've tried adding this property (FrameworkPathOverride) to the csproj:

<Project Sdk="Microsoft.NET.Sdk">
  <Import Project="..\..\tools\common.props" />
  <PropertyGroup>
    <TargetFrameworks>net40;net45;netstandard1.2</TargetFrameworks>
    <GeneratePackageOnBuild>False</GeneratePackageOnBuild>
    <FrameworkPathOverride>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0</FrameworkPathOverride>
  </PropertyGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net40' ">
    <Reference Include="System.Configuration" />
  </ItemGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'net45' ">
    <Reference Include="System.Configuration" />
  </ItemGroup>
  <PropertyGroup Condition=" '$(TargetFramework)' == 'netstandard1.2' ">
    <DefineConstants>$(DefineConstants);NETSTANDARD</DefineConstants>
  </PropertyGroup>
  <ItemGroup Condition=" '$(TargetFramework)' == 'netstandard1.2' ">
  </ItemGroup>
</Project>

That error then dissapears, but all my types and namespaces cannot be resolved, and I also get this build warning:

MSB3270 There was a mismatch between the processor architecture of the project being built "AMD64" and the processor architecture of the reference "C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll", "x86". This mismatch may cause runtime failures. Please consider changing the targeted processor architecture of your project through the Configuration Manager so as to align the processor architectures between your project and references, or take a dependency on references with a processor architecture that matches the targeted processor architecture of your project.

After setting the project's target framework to x86, the warning disappears, but still no types or namespaces can resolve.

I have all the necessary frameworks installed:

enter image description here

I am using Visual Studio 2017 on Windows 10.

like image 692
Dave New Avatar asked Jul 25 '17 12:07

Dave New


People also ask

How do I fix error MSB3644?

targets(1175,5): error MSB3644: The reference assemblies for framework ". NETFramework,Version=v4. 6.1" 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.

What is the reference assemblies folder?

Reference assemblies are usually distributed with the Software Development Kit (SDK) of a particular platform or library. Using a reference assembly enables developers to build programs that target a specific library version without having the full implementation assembly for that version.

How do I know if .NET is installed in CMD?

Open Start. Search for Command Prompt, right-click the top result, and select the Run as administrator option. Type the following command to determine the version of . NET installed and press Enter: reg query "HKLM\SOFTWARE\Microsoft\Net Framework Setup\NDP" /s To make sure that version 4.


1 Answers

Got the same error. The framework version was installed alright on my computer (running the installer for this specific version of the framework did nothing - it told me it was already installed). But the framework was not installed "as part of" Visual Studio.

What fixed it for me : Run the VS installer (re-download it from here if you lost it), click "modify" on Visual Studio, go to the "individual components" tab, and check things that are missing under the .NET category.

I didn't set any FrameworkPathOverride on my csproj.

like image 73
Zonko Avatar answered Sep 18 '22 08:09

Zonko