Edit

Share via


MSB3107 diagnostic code

This article describes the MSB3107 error code.

Message text

MSB3107: The specified project reference metadata for the reference 'referenced-project-name' is missing or has an invalid value:

Description

This error occurs when there's a problem with a ProjectReference in a project file. A ProjectReference element in MSBuild indicates a dependency on another project in the solution, for example, when you reference a class library project in a project that uses the library. In C# code, you can often look for the using directives in the project to see how it depends on APIs defined in the other project. The following code example shows a ProjectReference element that references Calculator.Library.

  <ItemGroup>
	  <ProjectReference Include="..\Calculator.Library\Calculator.Library.csproj" />
  </ItemGroup>

The ProjectReference may contain subelements that define metadata that specify details about the reference. Refer to the documentation for the supported metadata elements in Common MSBuild project items - ProjectReference.

Resolution

Review the ProjectReference element mentioned in the error message and correct any obvious errors such as spelling errors or typos in the value referenced in the error message, or other values provided in the ProjectReference.

If the error relates to a Project metadata with a GUID value, you can usually delete the Project metadata element and its value. Earlier versions of MSBuild expected a GUID value for the Project metadata element used to identify the project. If it is present, the GUID must be the correct project GUID (from the solution file) without any syntax errors. The following example shows the correct syntax with the Project metadata element and GUID value.

  <ItemGroup>
	  <ProjectReference Include="..\Calculator.Library\Calculator.Library.csproj">
		  <Project>{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</Project>
	  </ProjectReference>
  </ItemGroup>

You can also delete the ProjectReference element from the project file, and add a reference to that project again in the Visual Studio IDE. Adding a new project reference in Visual Studio recreates the elements in the project file with the most up-to-date metadata and values. See Add or remove references - Projects tab.

Check the ToolsVersion attribute. It's no longer needed in later versions of MSBuild, so you can try deleting it. If present, it should be 4.0 or later.

Applies to

All versions of MSBuild