问题
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
回答1:
Guys I'm terribly sorry you are running into this issue.
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:
- Rename the Microsoft.WebApplication.targets to Microsoft.WebApplication.targets.bak
- Install/Repair using the exe at http://go.microsoft.com/fwlink/?LinkId=253458
Can you try it out and let me know if it works or not?
回答2:
I had this problem, and it was fixed by adding:
<Target Name="GatherAllFilesToPublish">
</Target>
to the Project File.
回答3:
This worked for me fix - gather all files to publish error
- Right click the project and select Edit (project name).csproj. (e.g. Edit in notepad)
- Look for
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
Add the following above the line.
<PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">13.0</VisualStudioVersion> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath> </PropertyGroup>
Save and Reload project.
回答4:
Removing these installations solved the issue for me:
- Microsoft Web Publish - Visual Web Developer Express 2010
- Microsoft Web Publish - Visual Studio 2010
Reference
回答5:
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
回答6:
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" />
回答7:
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!
回答8:
Same problem with VS2017. You can try this, it worked for me.
- Unload the project and Edit csproj file
search the keyword "WebApplication.targets"
<Import Project="...\WebApplications\Microsoft.WebApplication.targets" ... >
COMMENT or REMOVE this line.(maybe two lines depending on "Condition")
- 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..
回答9:
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.
回答10:
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.
回答11:
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
回答12:
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" />
回答13:
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
回答14:
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>
回答15:
Sayed's solution did not work in my project which was upgraded using VS2012. But this worked
回答16:
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" />
回答17:
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.
回答18:
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
来源:https://stackoverflow.com/questions/10989051/why-do-i-get-the-error-the-target-gatherallfilestopublish-does-not-exist