Missing package error

When a solution is compiled I get 'missing package' error for Xamarin.Forms, asking me to restore the package. I have the version 1.2.1.6229 and it is looking for 1.1.1.6206. I have removed the package and added it back. But still I get the following error line:

C:\XPAs\Examples\UsingViewModel_XF\UsingViewModel_XF\UsingViewModel_XF\UsingViewModel_XF.csproj(5,5): Error: 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 ....\packages\Xamarin.Forms.1.1.1.6206\build\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\Xamarin.Forms.targets. (UsingViewModel_XF)

In the packages directory I have only two Xamarin.Forms subdirectories as follows:

  1. Xamarin.Forms.1.0.6186
  2. Xamarin.Forms.1.2.1.6229

How do I correct this error?

Answers

  • LeonPotgieterLeonPotgieter ZAMember ✭✭

    Thanks Matt, have been struggling with the for a while. Keeps happening every time I alternate between Windows/Mac and none of the other recommended solutions have worked. Yours solved the problem.

    Xamarin can't this be fixed? Is there anything we can do to stop this happening? Thanks.

  • mattwardmattward GBMember Xamurai

    @LeonPotgieter‌ - It is on my to do list but the bug is not yet fixed. There is an open bug on bugzilla where you can add yourself to the cc list if you want to be kept updated.

    Right now the only workaround is to make sure you only do the package updates in one IDE, either Visual Studio or Xamarin Studio.

    Visual Studio adds extra targets to the project file for the custom MSBuild tasks that Xamarin.Forms uses. Xamarin Studio currently does not add the extra targets but it also does not remove them or fix them if you update the NuGet package. This is the problem if you switch between Visual Studio and Xamarin Studio.

  • PhilippeBourquePhilippeBourque CAUniversity ✭✭

    I'm trying the very first code sample of the xamarin-forms-book-preview-2-master , PlatformVisuals.

    I've got this error and deleting the _Target _in the .csproj files worked, but after that, Visual Studio tell me that the type or namespace 'Xamarin' could not be found.

  • PhilippeBourquePhilippeBourque CAUniversity ✭✭

    Right click on the _Portable _ project -> Manage NuGetPackage and update the Xsmarin.Forms fixed the thing.

    Don't really understand why I have to update this package so often when working with samples.
    Maybe I will get this later after some exprience :smile:

  • Arun_Robinson_AArun_Robinson_A USMember ✭✭
    edited April 2017

    @mattward said:
    Probably the simplest thing to do is to edit your .csproj file in a text editor and remove the section that looks similar to the following:

      <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('..\..\packages\Xamarin.Forms.1.0.6188\build\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\Xamarin.Forms.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Xamarin.Forms.1.0.6188\build\portable-win+net45+wp80+MonoAndroid10+MonoTouch10\Xamarin.Forms.targets'))" />
      </Target>
    

    This worked for me, I faced this situation when moving solution form Visual Studio to Mac (Visual Studio for Mac)
    Thank you Matt :)

Sign In or Register to comment.