FIX: Error MSB4018: The "ValidatePackage" task failed unexpectedly. The project service does not contain the specified project.

Scenario:
Your SharePoint solution build fails with this error:
The "ValidatePackage" task failed unexpectedly.
The project service does not contain the specified project.
and the GUID provided is the ID of the project you are trying to build

Build log:

...

  CopyFilesToOutputDirectory:
  Copying file from "obj\Debug\Helpers.dll" to "D:\Builds\Binaries\Helpers.dll".
  Helpers -> D:\Builds\Binaries\Helpers.dll
  Copying file from "obj\Debug\Helpers.pdb" to "D:\Builds\Binaries\Helpers.pdb".
(...): error MSB4018: The "ValidatePackage" task failed unexpectedly. [D:\Builds\SPTest\Helpers\Helpers.csproj]
(...): error MSB4018: System.InvalidOperationException: The project service does not contain the specified project: 618318f6-eff6-4fa9-9b39-3a9a6febb01b. [D:\Builds\SPTest\Helpers\Helpers.csproj]
(...): error MSB4018:    at Microsoft.VisualStudio.SharePoint.Tasks.ValidatePackage.OnCheckParameters() [D:\Builds\SPTest\Helpers\Helpers.csproj]
(...): error MSB4018:    at Microsoft.VisualStudio.SharePoint.Tasks.BuildTask.Execute() [D:\Builds\SPTest\Helpers\Helpers.csproj]
(...): error MSB4018:    at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute() [D:\Builds\SPTest\Helpers\Helpers.csproj]
(...): error MSB4018:    at Microsoft.Build.BackEnd.TaskBuilder.<ExecuteInstantiatedTask>d__20.MoveNext() [D:\Builds\SPTest\Helpers\Helpers.csproj]
Done Building Project "D:\Builds\SPTest\Helpers\Helpers.csproj" (default targets) -- FAILED.

...

Fix C#:
Open the *.csproj in a text editor.
look for the <ProjectTypeGuids> entry and make sure the following guids are listed there:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    ...
    <ProjectTypeGuids>{BB1F664B-9266-4fd6-B973-E1E44974B511};{14822709-B5A1-4724-98CA-57A101D1B079};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    ...
  </PropertyGroup>
  ...
</Project>

Fix VB.NET:
Open the *.vbproj in a text editor.
look for the <ProjectTypeGuids> entry and make sure the following guids are listed there:
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    ...
    <ProjectTypeGuids>{BB1F664B-9266-4fd6-B973-E1E44974B511};{D59BE175-2ED0-4C54-BE3D-CDAA9F3214C8};{F184B08F-C81C-45F6-A57F-5ABD9991F28F}</ProjectTypeGuids>
    ...
  </PropertyGroup>
  ...
</Project>
Note:
The above guids identify these project types:

{BB1F664B-9266-4fd6-B973-E1E44974B511} – SharePoint 2011 project
{C1CDDADD-2546-481F-9697-4EA41081F2FC} – SharePoint 2013 project
{14822709-B5A1-4724-98CA-57A101D1B079} – Workflow C# project
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} – C# project
{D59BE175-2ED0-4C54-BE3D-CDAA9F3214C8} - Workflow VB.NET project
{F184B08F-C81C-45F6-A57F-5ABD9991F28F} - VB.NET project

1 comment to FIX: Error MSB4018: The "ValidatePackage" task failed unexpectedly. The project service does not contain the specified project.

  • I ran into a similar error message in TFS Build Service but with a different cause. This helped me: http://home.mpcomputers.de/system-invalidoperationexception-the-project-service-does-not-contain-the-specified-project/

Leave a Reply