title: Nuget.targets: error could not find a part of the path
body: <p>I trying the build a website via TeamCity. It is a three stage process. The first two restore NuGet packages and the third builds the website.</p>
  
  <p><a href="https://i.stack.imgur.com/sA5Bh.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sA5Bh.png" alt="enter image description here"></a></p>
  
  <p>Here is also the build steps for step 3.</p>
  
  <p><a href="https://i.stack.imgur.com/DlAGf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/DlAGf.png" alt="enter image description here"></a></p>
  
  <p>The first one passes with this only warning</p>
  
  <pre><code>Step 1/3: Restore the NuGet Packages for BalanceToBuy (NuGet Installer) (3s)
  [10:22:43][Step 1/3] scan: Searching for nuget.config files
  [10:22:43][scan] RepositoryPath was not extracted from NuGet.config file at C:\TeamCity\buildAgent\work\a606a53a0957ca4b\.nuget\NuGet.Config. Packages will be downloaded into default path: C:\TeamCity\buildAgent\work\a606a53a0957ca4b\packages.
  [10:22:43][scan] Found packages folder: C:\TeamCity\buildAgent\work\a606a53a0957ca4b\packages
  [10:22:43][scan] No repositories.config found at C:\TeamCity\buildAgent\work\a606a53a0957ca4b\packages\repositories.config
  [10:22:43][scan] Failed to resolve project reference from solution file: Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "http://localhost:66", "http://localhost:66", "{72D2746B-946D-4670-AB52-C087971DB810}"
  </code></pre>
  
  <p>The second one passes and the tird error our with these messages (22 of them)</p>
  
  <pre><code>[10:22:51][Buy.Business\Buy.Business.csproj] RestorePackages
  [10:22:51][RestorePackages] Exec
  [10:22:51][Exec] "C:\TeamCity\buildAgent\work\a606a53a0957ca4b\.nuget\NuGet.exe" install "C:\TeamCity\buildAgent\work\a606a53a0957ca4b\Buy.Business\packages.config" -source ""  -NonInteractive -RequireConsent -solutionDir "C:\TeamCity\buildAgent\work\a606a53a0957ca4b\ "
  [10:22:52][Exec] Restoring NuGet packages...
  [10:22:52][Exec] To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
  [10:22:52][Exec] EXEC 'Dapper' already has a dependency defined for 'System.Data.SqlClient'.
  [10:22:52][Exec] Installing 'log4net 2.0.8'.
  [10:22:52][Exec] Installing 'Dapper 1.60.6'.
  [10:22:52][Exec] Successfully installed 'log4net 2.0.8'.
  [10:22:52][Exec] C:\TeamCity\buildAgent\work\a606a53a0957ca4b\.nuget\NuGet.targets(100, 9): 'Dapper' already has a dependency defined for 'System.Data.SqlClient'.
  [10:22:52][Exec] C:\TeamCity\buildAgent\work\a606a53a0957ca4b\.nuget\NuGet.targets(100, 9): The 'Newtonsoft.Json 12.0.2' package requires NuGet client version '2.12' or above, but the current NuGet version is '2.8.60717.93'.
  [10:22:52][Exec] C:\TeamCity\buildAgent\work\a606a53a0957ca4b\.nuget\NuGet.targets(100, 9): error MSB3073: The command ""C:\TeamCity\buildAgent\work\a606a53a0957ca4b\.nuget\NuGet.exe" install "C:\TeamCity\buildAgent\work\a606a53a0957ca4b\BalanceToBuy.Business\packages.config" -source ""  -NonInteractive -RequireConsent -solutionDir "C:\TeamCity\buildAgent\work\a606a53a0957ca4b\ "" exited with code 1.
  </code></pre>
  
  <p>I fixed that problem by manually going to the CLI and updated the NuGet.exe it goes from version to to verions 5. I tried running it again and now I get a strange error.</p>
  
  <pre><code>[11:46:44][Exec] C:\TeamCity\buildAgent\work\a606a53a0957ca4b\.nuget\NuGet.targets(100, 9): Could not find a part of the path 'C:\TeamCity\buildAgent\work\a606a53a0957ca4b\ \packages\EnterpriseLibrary.Common.6.0.1304.0'.
  [11:46:44][Exec] C:\TeamCity\buildAgent\work\a606a53a0957ca4b\.nuget\NuGet.targets(100, 9): Could not find a part of the path 'C:\TeamCity\buildAgent\work\a606a53a0957ca4b\ \packages\FastMember.Signed.1.3.0'.
  [11:46:44][Exec] C:\TeamCity\buildAgent\work\a606a53a0957ca4b\.nuget\NuGet.targets(100, 9): Could not find a part of the path 'C:\TeamCity\buildAgent\work\a606a53a0957ca4b\ \packages\EntityFramework.6.2.0'.
  [11:46:44][Exec] C:\TeamCity\buildAgent\work\a606a53a0957ca4b\.nuget\NuGet.targets(100, 9): error MSB3073: The command ""C:\TeamCity\buildAgent\work\a606a53a0957ca4b\.nuget\NuGet.exe" install "C:\TeamCity\buildAgent\work\a606a53a0957ca4b\BalanceToBuy.Utility\packages.config" -source ""  -NonInteractive -RequireConsent -solutionDir "C:\TeamCity\buildAgent\work\a606a53a0957ca4b\ "" exited with code 1.
  </code></pre>
  
  <p>I noticed that there is a space in the <code>-solutionDir "C:\TeamCity\buildAgent\work\a606a53a0957ca4b\ "</code><br>
  <strong>How is that getting there?</strong></p>