Why do I get the error "The target GatherAllFilesToPublish does not exist"?

AzureVisual Studio-2010

Azure Problem Overview


I have recently installed the new Azure development tools for Visual Studio 2010 service pack 1. Every time that I try to publish an existing website (using file system deployment) I get the following error:

> The target "GatherAllFilesToPublish" does not exist in the project.

Can anyone tell me what I am missing?

Thanks

Azure Solutions


Solution 1 - Azure

I think that I know what the issue is. When you install the Azure SDK bits it installs some VS Web Publish updates. One of these updates the file at

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets

Based on how our setup is defined if that file has an updated timestamp (for whatever reason) then when you install the new component the file does not get updated.

To resolve this you should be able to follow the steps below:

Solution 2 - Azure

I had this problem, and it was fixed by adding:

<Target Name="GatherAllFilesToPublish">
</Target>

to the Project File.

Solution 3 - Azure

This worked for me fix - gather all files to publish error

  1. Right click the project and select Edit (project name).csproj. (e.g. Edit in notepad)

  2. Look for <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />

  3. Add the following above the line.

    <PropertyGroup> 
     <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">13.0</VisualStudioVersion>
     <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
    </PropertyGroup>
    
  4. Save and Reload project.

Solution 4 - Azure

I ran into this issue with VS 2017 and I tried manually changing the csproj file as suggested here and none of the suggested fixes worked for me. I ran across this nuget package. Installing it worked for me.

MSBuild.Microsoft.VisualStudio.Web.targets

Solution 5 - Azure

Removing these installations solved the issue for me:

  • Microsoft Web Publish - Visual Web Developer Express 2010
  • Microsoft Web Publish - Visual Studio 2010

Reference

Solution 6 - Azure

Same problem with VS2017. You can try this, it worked for me.

  1. Unload the project and Edit csproj file

  2. search the keyword "WebApplication.targets"

     <Import Project="...\WebApplications\Microsoft.WebApplication.targets" ... >
    

COMMENT or REMOVE this line.(maybe two lines depending on "Condition") 3. Save and Reload project

In this step, it will prompt you to install some package about 500M...

After that, reload project, then it works!

I guess I just miss some components when I install VS 2017.

Also I notice the MSBuild Path is quite different in VS2017, but maybe that's not related to the problem cuz it uses relative path in the csproj file..

Solution 7 - Azure

I had similar issue when I wanted to publish my ASP.Net application to Windows Azure. After many trial and error finally this solution worked for me. This does not need any renaming of files or any installation / reinstallation of hotfixes / patches. Here is what you have to do:

Open the ASP.Net project file (.csproj) in Wordpad / Notepad and find the line looking similar to this:

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

Replace it with line as given below:

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

Solution 8 - Azure

I realize this in an old question, but I ran into it recently and here is how I solved it.

Background: I had an old project that I upgraded to VS studio 13. It looks like the project file wasn't upgraded properly.

There are references to VS v10.0, in the csproj file, but I am running VS 13 which is really "v12.0".

So I told the csproj file to use the "v12.0" folder, not a "v10.0" folder.

This is what I had:

<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="$(SolutionDir)\..\BuildTools\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
<Import Project="$(SolutionDir)\..\BuildTools\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

This is what I changed it into:

<PropertyGroup>
  <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.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)' != ''" />

Now my publishing to the filesystem works!

Solution 9 - Azure

I had a similar issue and resolved it by using the steps provided by Sayed.

The file I renamed was in the v10.0 directory though.

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets.

The original file that was there was dated 18-Jan-2011, after renaming it with a .bak extensions then reinstalled KB2591016, publishing seems to be working again. The new date of the file Microsoft.WebApplication.targets is now 11-Aug-2011.

Solution 10 - Azure

I've been struggling with the same problem with Visual Studio 2013 (and 2015).

The crucial fix for me was to add the VSToolsPath property setting, which was missing in my project file, for whatever reason.

I added this into the <PropertyGroup> directive:

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

As a side note: My project file is also referencing the v10.0 version of the Microsoft.WebApplication.targets file, but that seems to be okay.

Solution 11 - Azure

I had the same error. Somehow this line was missing.

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

Added it just below

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

Works fine now

Solution 12 - Azure

I have the same issue in VS2013, the solution I found was by creating a new empty web application project can copying the following lines from it into my old website project: At the top:

<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />

<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" />

Solution 13 - Azure

Right click the project and select Edit (project name).csproj. (e.g. Edit in notepad) Look for Add the following above the line.

13.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) Save and Reload project.

This really work for me, Thanks

Solution 14 - Azure

For Visual Studio 2017 - it should be added after the block in the .csproj file, use notepad and look for ".targets" to locate it...

I created a new VS 2017 project and this is working for me (with no warnings):

  <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" />
  <Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
    <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
  </Target>

Solution 15 - Azure

I had the same issue: I created the project in VS 2010, and had to publish from VS 2019. None of the solutions here worked for me, and I'd been with the issue for about a day.

What did work came from this link: http://www.dotnetxp.com/visual-studio-error-publish-target-gatherallfilestopublish-not-exist-project/

This is what I did:

** Unloaded offending project.

** Open csproj file in text editor.

** Find this line

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

and replace with this. I use 16.0 because that's the version I'm using (vs2019).

<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">16.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\v16.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

** Reload project and publish.

Worked like a charm.

Solution 16 - Azure

Sayed's solution did not work in my project which was upgraded using VS2012. But this worked

Solution 17 - Azure

If editing in VS2012 (Visual Studio 2012) a VS2010 project try this. Edit the csproj file from:

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

And change to:

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

Solution 18 - Azure

Since the issue cannot be reproduced on my side, I would like to suggest you to try to reinstall the SDK.

Please try to remove the old SDK completely before installing the new one.

Best Regards,

Ming Xu.

Solution 19 - Azure

Same issue I have Fixed. Please check if some files are missing into solution. if you are facing error like Error - The target "GatherAllFilesToPublish" does not exist in the project. Then just open .proj file and delete this line <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

You get actual error or those missing files into solution

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionJoeView Question on Stackoverflow
Solution 1 - AzureSayed Ibrahim HashimiView Answer on Stackoverflow
Solution 2 - AzureEmanuele CiriachiView Answer on Stackoverflow
Solution 3 - AzurePhillyNJView Answer on Stackoverflow
Solution 4 - AzureBuddy JView Answer on Stackoverflow
Solution 5 - AzureEduardo CampañóView Answer on Stackoverflow
Solution 6 - AzureJoeyView Answer on Stackoverflow
Solution 7 - AzureRashidView Answer on Stackoverflow
Solution 8 - AzureVilhelm H.View Answer on Stackoverflow
Solution 9 - AzureSprinkleView Answer on Stackoverflow
Solution 10 - AzurederFunkView Answer on Stackoverflow
Solution 11 - AzureStefanHaView Answer on Stackoverflow
Solution 12 - AzurelearnerplatesView Answer on Stackoverflow
Solution 13 - AzurePrathamView Answer on Stackoverflow
Solution 14 - AzureYovavView Answer on Stackoverflow
Solution 15 - AzurefdkgfosfskjdlsjdlkfsfView Answer on Stackoverflow
Solution 16 - AzureRush FrisbyView Answer on Stackoverflow
Solution 17 - AzureSushiGuyView Answer on Stackoverflow
Solution 18 - AzureMing Xu - MSFTView Answer on Stackoverflow
Solution 19 - AzureAppasaheb TawaleView Answer on Stackoverflow