Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nuget.targets: error could not find a part of the path

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.

enter image description here

Here is also the build steps for step 3.

enter image description here

The first one passes with this only warning

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

The second one passes and the tird error our with these messages (22 of them)

[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.

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.

[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.

I noticed that there is a space in the -solutionDir "C:\TeamCity\buildAgent\work\a606a53a0957ca4b\ "
How is that getting there?

like image 400
Franco Pettigrosso Avatar asked Nov 05 '19 16:11

Franco Pettigrosso


People also ask

Could not find the part of the path nuget error?

The issue could be filepaths in your CSPROJ file. Most common cause is project restructure and the location of packages has changed. In addition to NUGET references in the CSPROJ, there could be a few other spots in the footer of the CSPROJ or the header portion for MSTest adapter entries.

How do I fix a missing nuget package?

You can restore packages manually with nuget restore , dotnet restore , msbuild -t:restore , or through Visual Studio. The dotnet build and dotnet run commands automatically restore packages, and you can configure Visual Studio to restore packages automatically when it builds a project.

Where are nuget targets?

config and a nuget. targets file are created within a . nuget folder, and all projects that have NuGet package references will be modified to import the NuGet.

Where is the path of nuget EXE?

Install the official nuget.exe in your PC. Create a Symbolic Link here: %localappdata%\microsoft\winget\links. Make the nuget.exe globally available for your user to call it from anywhere, since the aforementioned directory should be present in your user's PATH variable.


1 Answers

This issue should have been solved in March. I'm surprised you'd get it now, as it implies that you created your solution (With VS2010, 2012 or 2013) between the 20th of December 2018 and the 5th of March 2019, but only just updated to a newer nuget.exe now. Anyway, if you want to keep using this old, outdated way of doing NuGet restores, you need to manually edit your nuget.targets file as I wrote in the GitHub issue.

However, I still recommend migrating to automatic package restore. It means you'll need an extra step in your CI pipeline to do the restore before building, but Visual Studio 2015 onwards no longer has functionality to add NuGet restore in the way that your solution is doing.

like image 157
zivkan Avatar answered Oct 15 '22 15:10

zivkan