How To Solve “GatherAllFilesToPublish” Error?

Issue:

I’m getting an error “GatherAllFilesToPublish”  when tried to publish my code. What’s happening to my csproj file?

---------------------------
Publish failed
---------------------------
Publish has encountered an error.

Build failed. Check the Output window for more details.


A diagnostic log has been written to the following location:

"C:\Users\username\AppData\Local\Temp\1\tmpC98.tmp"
---------------------------
OK   
---------------------------

Error MSB4057: The target "GatherAllFilesToPublish" does not exist in the project

 

Environment:

Windows 10, Visual Studio 2019, C# Project with Framework 4.0

Resolution:

This error is due to incorrect setting on project file (*.csproj). Please follow step-by-step instructions below.

Step-by-step instructions:-

  1. Open you project under Visual Studio
  2. Right click on project name and select “Unload Project”
  3. Right click on project name again and select “Edit *.csproj”
  4. Scroll down to the bottom of the file and you should see following line:
    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" />
  5. Replace above line with following two lines:
    <Import Project="$(VSToolsPath)\WebApplications\Microsoft.WebApplication.targets" Condition="'$(VSToolsPath)' != ''" />
    
    <Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" Condition="false" />

  6. Save the file and right click on project name to Reload the project
  7. Try publish again to see if it solves the issue

Troubleshoot:

If fail again, please verify by going through step 2 to 4 to see if two lines still there.

 

TFS Build Error on NuGet Restore Task ECONNREFUSED

Issue:

I’m trying to add third new agent to default pool and get an error message on NuGet restore task during testing. The error is “##[error]connect ECONNREFUSED 152.199.4.184:443”. What did I do wrong?

2019-06-23T16:12:22.1309391Z ##[section]Starting: NuGet restore
2019-06-23T16:12:22.1465660Z ==============================================================================
2019-06-23T16:12:22.1465660Z Task         : NuGet Restore
2019-06-23T16:12:22.1465660Z Description  : Restores NuGet packages in preparation for a Visual Studio Build step.
2019-06-23T16:12:22.1465660Z Version      : 1.0.1
2019-06-23T16:12:22.1465660Z Author       : Microsoft Corporation
2019-06-23T16:12:22.1465660Z Help         : [More Information](https://go.microsoft.com/fwlink/?LinkID=613747)
2019-06-23T16:12:22.1465660Z ==============================================================================
2019-06-23T16:12:23.1623101Z [command]C:\Windows\system32\chcp.com 65001
2019-06-23T16:12:23.1623101Z Active code page: 65001
2019-06-23T16:12:24.2466118Z ##[error]connect ECONNREFUSED 152.199.4.184:443
2019-06-23T16:12:24.2466118Z ##[section]Finishing: NuGet restore

Environment:

TFS 2019, Visual Studio 2019, Build Server Agents Version 2.122.1 with Proxy, Build Definition with NuGet Restore Version 1.0.1

Resolution:

Most likely the problem is with connection to outside world. But in this case, it was because it’s missing NuGet.exe file under agent folder \_work\_tool\NuGet\4.0.0\x64\nuget.exe. To make sure you have this file, please check under your TFS Agent folder under _work\_tool\NuGet\4.0.0\x64. Please follow below instructions to check if web proxy setup correctly.

Step-by-step instructions:-

  1. Open File Explorer and browse to where you install TFS Agent
  2. First locate a proxy file named: .proxy (you may need to show hidden file to see it)
  3. Open .proxy file with Notepad and make sure the web proxy gateway name is correct with http/https prefix and port number
  4. Second, check \externals\vstshost\LegacyVSTSPowerShellHost.exe.config file for web proxy settings
  5. Open LegacyVSTSPowerShellHost.exe.config and check if you have defaultProxy attribute under system.net section
      <system.net>
        <defaultProxy useDefaultCredentials="true">
          <proxy proxyaddress="http://your.proxy.com:8080" bypassonlocal="true" />
        </defaultProxy>
      </system.net>
  6. Third, check if you have nuget.exe install under agent folder \_work\_tool\NuGet\4.0.0\x64\
  7. Four (optional), sync \_work\_tasks folder with other agent build server so all build servers have same packages installed
  8. Restart the VSTS Agent service and try to build again

Troubleshoot:

To make sure build server is using proxy to connect to external source, check with firewall log.

Reference:

Create Build Definition