14

I've checked that the same error occurred in the past with earlier vs .net versions but I am facing this issue in VS 2017 while trying to upgrade from VS Community 15.3.5 to 15.4.

  • I first installed using the web installer by choosing the options,
  • some how there were a couple of errors & the download + installation took over 9+ hours

visual studio was working and compiling project except that this had the problem 'The target "GatherAllFilesToPublish" does not exist in the project'.

Then I tried downloading the entire setup using "vs_community.exe --layout "C:\MyFolder" --lang en-US" which again took over 9 hours to finish download. Re-ran the setup choosing Repair, again the same issue.

Is any one aware of a quicker way to solve this above problem?

Muthu
  • 2,675
  • 4
  • 28
  • 34

7 Answers7

24

I had similar problem and it solved by changing csproj file:

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

changed to

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" Condition="true" />
  • 1
    I guess this error occurs when a project created with an older version of VS is loaded in a newer version. I came across this error too. I opened a VS2010 project in VS2017 and got this error. Making changes as suggested by Mohammad Reza Sadreddini worked for me. – Shrewdroid Sep 25 '18 at 13:44
  • Same here. I was upgrading from a VS project back in 2008 over to VS2017 and yeah the migration did not work as it did not update that line. Now it works. Thanks – Fandango68 Jan 23 '19 at 06:05
9

I had same issue (Visual Studio 2017). Install - " MSBuild.Microsoft.VisualStudio.Web.targets " nuget package to visual studio. And then try to publish.

Jain
  • 161
  • 2
  • 4
  • Our project relies on [MSBuild.Microsoft.VisualStudio.Web.targets](https://www.nuget.org/packages/MSBuild.Microsoft.VisualStudio.Web.targets). I updated Visual Studio 2017 yesterday and got the _"GatherAllFilesToPublish" does not exist in the project'._ error. All I had to do to fix it was to update [MSBuild.Microsoft.VisualStudio.Web.targets](https://www.nuget.org/packages/MSBuild.Microsoft.VisualStudio.Web.targets) to the latest version (v14.0.0.3) and that solved the issue. – Ben Bailey Nov 20 '19 at 13:32
  • I had this problem with VS2019 and solved by installing Web.targets through Nuget – keno Jul 05 '22 at 12:57
1

Just install the ASP.Net Web Deployment component for VS2017, it worked for me.

1

Similar issue occurred with me after I upgraded project from previous version to VS 2017. I had to make following changes in the csproj file.

  1. Uncomment the following part of code from csproj file ( It was already present as comment, not sure why it did not change while upgrade automatically. If you do not have it, add below lines of code.)
<PropertyGroup>
    <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 
    </VSToolsPath>
</PropertyGroup>
  1. Make sure below 3 imports are present in the csproj file. (These were also present, but if not, add manually)
<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" />

And then I was able to publish the project.

Chaitanya Gadkari
  • 2,669
  • 4
  • 30
  • 54
0

I wonder what packages are changing these paths?

Mine is as follows:

<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildProgramFiles32)\MSBuild\Microsoft\VisualStudio\v14.0</VSToolsPath>

changed to

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

same issue as this: https://stackoverflow.com/a/48545538/231821

Jim
  • 14,952
  • 15
  • 80
  • 167
0

I had this same problem, I updated Visual Studio 2017 to a newer version via the installer. The installer never completed successfully. It completed with some errors which I just ignored so many of the components weren't installed which came after the components with errors. After I resolved the error components, the rest of the installation finally completed successfully and I could publish again with no problems.

I think some of the components which wasn't installed previously was older versions which was not compatible with the new update.

Try installing/updating your visual studio completely with no errors.

Pierre
  • 8,397
  • 4
  • 64
  • 80
0

For me work this solution

Edit project file and add this "PropertyGroup" (csproj)

<!--Visual Studio 2022-->
<PropertyGroup Condition="'$(VisualStudioVersion)' == '17.0'">
    <VisualStudioVersion>17.0</VisualStudioVersion>
    <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>

and then the line

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

works ok!

blogprogramisty.net
  • 1,714
  • 1
  • 18
  • 22