I enabled auto-restore feature for my project under Visual Studio but when I switched to MAC and Xamarin Studio I was unable to restore those packages:
xxx.csproj: Error: This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them
To do that, go to Tools, NuGet Packaged Manager, then go to Package Manager Settings. Go to the General section, and then make sure you have a checkmark for Allow NuGet to download missing packages and also to automatically check for missing packages during the build in Visual Studio. So click on OK.
Restore by using MSBuild You can use msbuild -t:restore to restore packages in NuGet 4. x+ and MSBuild 15.1+, which are included with Visual Studio 2017 and higher. This command restores packages in projects that use PackageReference for package references.
NuGet packages contain reusable code that other developers make available to you for use in your projects. See What is NuGet? for background. Packages are installed into a Visual Studio for Mac project using the NuGet Package Manager.
Open your project or solution in Visual Studio, and select Tools > NuGet Package Manager > Package Manager Console to open the Package Manager Console window.
By enabled auto-restore feature I am assuming you are referring to the MSBuild based restore which adds a NuGet.targets file to your project.
That particular error is coming from the MSBuild file:
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>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 {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
The error condition suggests that it cannot find the .nuget\NuGet.targets file. So does this exist? Does the case of the path exactly match?
Also note that there is a problem with the NuGet.targets file on the Mac since it uses a feature of MSBuild which is not supported on Mono. The latest NuGet.targets file available from codeplex may fix this.
It might be easier to remove the MSBuild based package restore and install the NuGet addin for Xamarin Studio, and use the package restore feature from inside Xamarin Studio. To restore from within Xamarin Studio, you can right click the project and select Restore Packages.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With