xamarin git pull nuget package error - c#

I am new in Xamarin android development.
I take the code pull from git.
After that i opened my solution in visual studio.
I cleaned the solution - now it is fine.
then i trying to build the solution it is showing the error.
>Restoring NuGet packages...
To prevent NuGet from restoring packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages during build.'
NuGet Package restore failed for project app: Unable to find version '2.0.0' of package 'FastAndroidCamera'.
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\: Package 'FastAndroidCamera.2.0.0' is not found on source 'C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\'.
https://api.nuget.org/v3/index.json: Unable to load the service index for source https://api.nuget.org/v3/index.json.
An error occurred while sending the request.
The remote name could not be resolved: 'api.nuget.org'
1>------ Rebuild All started: Project: app, Configuration: Debug Any CPU ------
1>D:\PRANAV\TOLL\GIT\MobileApp-12-06-2018\MobileApp\app\app.csproj(467,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is ..\packages\Xamarin.Build.Download.0.4.3\build\Xamarin.Build.Download.props.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========\
This is the error that i am getting . So guys can you figure where i am doing the mistakes ?

According to the error message,
To prevent NuGet from restoring packages during build, open the Visual
Studio Options dialog, click on the Package Manager node and uncheck
'Allow NuGet to download missing packages during build.'
It seems the project use the older now deprecated NuGet package restore that is MSBuild based and runs NuGet.exe on every build. These messages are from NuGet.exe.
Check the similar issue here.
To resolve this issue, you should make sure to upgrade to the latest version of NuGet which does package restore automatically instead of MSBuild based NuGet package restore.
You're going to want to delete the NuGet targets (delete the .nuget folder and then manually edit your .csproj files and remove the lines that import the NuGet.targets file). This is no longer needed. Using the new way to restore nuget package, the NuGet packages will be automatically restored by Visual Studio just before the build.
See this post by David Ebbo for more information: http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html and the blog how to switch from "Enable Package Restore" to "Automatic Package Restore"
Hope this helps.

Related

Why does dotnet build on a .NET Framework 4.5 project throw "This project references NuGet package(s) that are missing"?

The sample NotepadAndCalculatorTest project built in VS Code using the terminal command dotnet build throws the following errors:
C:\Program Files\dotnet\sdk\5.0.401\Microsoft.Common.CurrentVersion.targets(820,5): error : The BaseOutputPath/OutputPath property is not set for project 'NotepadCalculatorTest.csproj'. Please check to make sure that you have specified a valid combination of Configuration and Platform for this project. Configuration='Debug' Platform='AnyCPU'. You may be seeing this message because you are trying to build a project without a solution file,
and have specified a non-default Configuration or Platform that doesn't exist for this project. [C:\Users\<username>\VSCode Projects\WinAppDriverTryout\Test\Samples\C#\NotepadAndCalculatorTest\NotepadCalculatorTest.csproj]
Or:
NotepadCalculatorTest.csproj(109,5): error : This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is packages\MSTest.TestAdapter.1.2.0\build\net45\MSTest.TestAdapter.props.
Could someone point me towards a possible way to get rid of the errors?
dotnet build carries out an implicit restore as part of the command.
This uses dotnet restore which does not support project references in packages.config & is exactly what this project is using.
dotnet restore only supports .csproj package references.
That's why, this project builds perfectly fine in Visual Studio but dotnet build throws errors.
You can migrate packages.config to package references by right-clicking on the file within Visual Stduio and clicking migrate, however that still won't fix your problem as dotnet cli works properly with .NET Framework only if the project was created using the dotnet new command.
I assume this project was created in Visual Studio since it has a Visual Studio solution file - .sln - and so commonly have a differently structured .csproj format.
This then usually breaks some CLI commands, even if you migrate the references in this case.
You have 2 workarounds.
1. Use nuget restore
The easiest option is to download the NuGet CLI executable from here, taken from the downloads page.
If you are not on Windows, use this guide by Microsoft.
Add it to your PATH or place it in the root folder of the project.
Run nuget restore, which is compatible with packages.config (run .\nuget restore if you're inside PowerShell to trust the command as PowerShell does not does not load commands from the current location by default for security).
Your should get output similar to this:
PS C:\Users\StackOverflow\NotepadAndCalculatorTest> .\nuget restore
MSBuild auto-detection: using msbuild version '16.9.0.16703' from 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\bin'.
Restoring NuGet package Microsoft.WinAppDriver.Appium.WebDriver.1.0.1-Preview.
Restoring NuGet package Selenium.Support.3.8.0.
Restoring NuGet package Selenium.WebDriver.3.8.0.
Restoring NuGet package Castle.Core.4.2.1.
Restoring NuGet package MSTest.TestFramework.1.2.0.
Restoring NuGet package Newtonsoft.Json.10.0.3.
Restoring NuGet package MSTest.TestAdapter.1.2.0.
Adding package 'MSTest.TestFramework.1.2.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'Selenium.Support.3.8.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'Castle.Core.4.2.1' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'Microsoft.WinAppDriver.Appium.WebDriver.1.0.1-Preview' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'Selenium.WebDriver.3.8.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'Newtonsoft.Json.10.0.3' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Adding package 'MSTest.TestAdapter.1.2.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'Microsoft.WinAppDriver.Appium.WebDriver.1.0.1-Preview' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'Selenium.Support.3.8.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'Selenium.WebDriver.3.8.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'Castle.Core.4.2.1' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'Newtonsoft.Json.10.0.3' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'MSTest.TestAdapter.1.2.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
Added package 'MSTest.TestFramework.1.2.0' to folder 'C:\Users\StackOverflow\NotepadAndCalculatorTest\packages'
NuGet Config files used:
C:\Users\StackOverflow\AppData\Roaming\NuGet\NuGet.Config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config
Feeds used:
C:\Users\StackOverflow\.nuget\packages\
https://api.nuget.org/v3/index.json
C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Installed:
7 package(s) to packages.config projects
Then run dotnet build.
It won't try to run dotnet restore as the packages have already been restored by NuGet already so you won't get any errors:
PS C:\Users\StackOverflow\NotepadAndCalculatorTest> dotnet build
Microsoft (R) Build Engine version 16.9.0+57a23d249 for .NET
Copyright (C) Microsoft Corporation. All rights reserved.
Determining projects to restore...
Nothing to do. None of the projects specified contain packages to restore.
NotepadCalculatorTest -> C:\Users\StackOverflow\NotepadAndCalculatorTest\bin\Debug\NotepadCalculatorTest.dll
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:01.08
2. Port the project
The 2nd workaround is to create a new project using dotnet new & port the code over so that your .csproj file works with dotnet restore and subsequently, dotnet build.
I would recommend option 1 unless you don't want to restore via NuGet.

nuget restore failure for vs solution

We currently get the following error on the build server with no related changes we can notice. What could be wrong or where should we start debug it?
...
RestorePackages:
"E:\AzureBuildAgentWorkingFolder\2\s\Server\.nuget\NuGet.exe" install "packages.config" -source "" -NonInteractive -solutionDir "E:\AzureBuildAgentWorkingFolder\2\s\Server\ "
All packages listed in packages.config are already installed.
##[error]C:\Program Files\dotnet\sdk\3.1.101\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(234,5): Error NETSDK1064: Package Microsoft.AspNet.SignalR.Client, version 2.4.0 was not found. It might have been deleted since NuGet restore. Otherwise, NuGet restore might have only partially completed, which might have been due to maximum path length restrictions.
...
We have checked and the folder and files for the signalr (Microsoft.AspNet.SignalR.Client, version 2.4.0) package exists.
I have tried:
clean entire build folder
adding msbuild restore to pipeline
different nuget versions from 4 -> 5
Microsoft.AspNet.SignalR.Client version 2.4.0 and 2.4.1
manual build with VS on the build server (works)

Visual Studio - Microsoft.bcl.build.targets, unload project option not available

I'm getting the following error:
This project references NuGet packages(s) that are missing on this computer. Use Nuget Package Restore to download them... This missing file is ..\packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets
When I run "Install-Package Microsoft.Bcl.Build -Version 1.0.21" in my Package Manager Console nothing happens.
I've tried to unload the project but, when I right click on the project name I don't see an option for "Unload".
This is the only error I'm seeing when I build the project.

Where to place NuGet

I have downloaded Google WEB API sample project. Solution explorer contains .nuget folder that is missing on my machine. NuGet itself is installed on my system. Currently build project rices error:
Error 1 This project references NuGet package(s) that are missing on
this computer. Enable NuGet Package Restore to download them. For
more information, see http://go.microsoft.com/fwlink/?LinkID=322105.
The missing file is
C:\pro\gplus-quickstart-csharp-master\.nuget\NuGet.targets. C:\pro\gplus-quickstart-csharp-master\gplus-quickstart-csharp\gplus-quickstart-csharp.csproj 196 5 gplus-quickstart-csharp
If I remove .nuget folder I have the same error.
How to configure NuGet in my system to make project build?
Have you tried Tools -> Options -> Nuget Package Manager and then selecting Allow Nuget to download missing packages?
Then rebuild your solution

Can't build solution because of missing NuGet references

Like title says, I can not build my solution(C#) as NuGet is spitting out this error
This project references NuGet package(s) that are missing on this
computer. Use NuGet Package Restore to download them. For more
information, see http://go.microsoft.com/fwlink/?LinkID=322105. The
missing file is ..\packages\Fody.1.26.1\build\Fody.targets.
When I run Get-Package, it says no packages are installed.
How do I get rid of this(I have no need for the package anymore).
Thanks
You don't want to use the project based nuget package restore!
Make sure you have the latest Nuget version (Tools -> Extensions and Updates)
When you go to build the project it should tell you it needs to download the nuget packages (or might just auto download them).
Edit not sure whats with the downvotes:
http://blog.davidebbo.com/2014/01/the-right-way-to-restore-nuget-packages.html
To find the menu item: "enable nuget package restore" right-click in the solution explorer on the solution - not on the project.
You get a message:
Do you want to configure this solution to download and
restore missing NuGet packages during build?
Press Ctrl+Q then type "Package Manager Console", This will bring up a console like interface.
Type in
Uninstall-Package Fody
and press enter will remove this package for you

Categories