Visual Studio Error On Publish : The target “GatherAllFilesToPublish” does not exist in the project

How to fix The target “GatherAllFilesToPublish” does not exist in the project error

 

When we upgrade the visual studio and try to publish a project which created from an old visual studio version, we get an error something like “The target “GatherAllFilesToPublish” does not exist in the project”. The reason seems to be the project files haven’t upgraded correctly.

The solution for this error is to update the project files.

First unload the project end go to edit mode.

In the top of the project file you can see the section “<Project ToolsVersion=”xx.x”……..”. In here you will see the old version of visual studio. Change this to new version.

Ex  : If your project created from VS 2013 then you have version 12.0. If your new version is vs 2017 then change the value to 15.0

Then find the below section in project file

<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />

Add below code before the above line

<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

Then add below line after that line

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

 

Finally that section will look like below

<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

 

Now save the file and reload the project. This should fix the error :The target “GatherAllFilesToPublish” does not exist in the project.

Now you should be able to publish the project.

 

Sajith Dilhan on FacebookSajith Dilhan on Linkedin
Sajith Dilhan
Software Developer at Sana Commerce

Leave a Reply

Your email address will not be published. Required fields are marked *