Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / DevOps / deployment

Error MSB4057: The Target Package Does Not Exist in the Project.

5.00/5 (1 vote)
30 Jun 2016CPOL1 min read 26.4K  
MSDeploy package was not found (MSB4057)
Adding the entry $(MSBuildExtensionsPath32)MicrosoftVisualStudiov$(VisualStudioVersion) to the project file resolves the MSB4057: The target Package does not exist in project error and ensures project compatibility when opening in later versions of Visual Studio.

Background

I had been struggling with the error "MSB4057: The target Package does not exist in project" and found many articles on how to fix it. However, unfortunately, none of them helped me. So, I took a step back and evaluated the projects closely. In our shop, we work with branching. The issue was that the same project in one branch worked (when MSDeploy was executed), another did not. When I compared the projects, I found this one entry (see below) was missing in the project file that was throwing the exception. When I would add it in the project (that was throwing the exception), MSDeploy worked, (for confirmation) when I removed it, it failed again.

Posting in the hopes to help someone that does not have a working project.

$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)

Using the Code

Entering the following line within the project fixed the issue.

$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)

The full entry that you use to paste into your project file looks like the following. Please be aware that all configurations should be researched for your particular project. I added a few additional articles to review in order to understand the entry.

XML
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" 
Condition="'$(VSToolsPath)' != ''" />

Points of Interest

The purpose for this entry is to help project compatibility when opening a project in later versions of Visual Studio.

Other articles to better understand the entry:

History

  • 30th June, 2016: Initial version

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)