If you happen to encounter the following error “The target “GatherAllFilesToPublish” does not exist in the project.” while publishing your project to local filesystem after upgrading Visual Studio 2010 projects to Visual Studio 2012, it is most likely an issue due to the upgrade process.

While in TFS environment, a comparison is made between the csproj files. It seems that the following missing lines caused the issue:
<PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)MicrosoftVisualStudiov$(VisualStudioVersion)</VSToolsPath> </PropertyGroup>
By adding back the following lines before this line will eventually solve the issue. <Import Project=”$(MSBuildToolsPath)Microsoft.CSharp.targets” />
Solution:
- Right click project –> Unload Project. It will show the project as unavailable.
- Right click project again, this time select Edit (project name).csproj.
- Look for <Import Project=”$(MSBuildToolsPath)Microsoft.CSharp.targets” />
- Add the following above the line.
<PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)MicrosoftVisualStudiov$(VisualStudioVersion)</VSToolsPath> </PropertyGroup>
- End result:
<PropertyGroup> <VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion> <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)MicrosoftVisualStudiov$(VisualStudioVersion)</VSToolsPath> </PropertyGroup> <Import Project="$(MSBuildToolsPath)Microsoft.CSharp.targets" />
- Save and Reload project.
[adrotate banner=”1″]
Issue should be solved.
Note: This error is somewhat different from the issue caused in Windows Azure projects.
“GatherAllFilesToPublish” Error in Upgraded VS2012 Projects http://t.co/YkuDtFLDKg
this does not work for me 🙁
May I know if your code is written in C# or VB?
Dawa
thank it’s work, but when i want to commit with my build test i have a error :
C:WindowsMicrosoft.NETFramework64v4.0.30319Microsoft.Common.targets (2482): Unable to find manifest signing certificate in the certificate store.
Any idea about this?
Thank you again
The problem with the solution you have provided is that it breaks builds on certain build servers, because it looks for the wrong version of VSTools. It seems to always want version 11.0 when building .Net 4.0 projects.
Adding an empty target called GatherAllFilesToPublish in the .csproj file will prevent errors, but you might end up with empty directories when publishing, or all source files are also published.
Hi Vegard Helland,
Thank you for your insight. Perhaps you may share your solution on how to resolve this issue since at this moment I am unable to resolve it using other methods.
Regards,
Dawa
Hi,
After a days worth of research and work, I ended up creating a new solution with new projects and just copy the source files from the old solution.
A few of the hacks I tried worked well, but they would break on the next Visual Studio upgrade as they all required manual editing of the .csproj file with version numbers.
Built in publish functionality in Visual Studio is abandoned here now. We write nant or powershell scripts to do the job for us.