Is it possible to use “PackageReference” in Xamarin.Android or Xamarin.iOS projects?

前端 未结 1 455
悲哀的现实
悲哀的现实 2020-12-30 03:57

By default, Xamarin.iOS and Xamarin.Android projects use a package.config file to manage Nuget dependencies. The Microsoft page about Package references (Packag

相关标签:
1条回答
  • 2020-12-30 04:46

    Yes, PackageReference works for Xamarin.iOS|Android projects and in Visual Studio for Windows or Mac or via the cmd-line (nuget restore or via msbuild).

    Add the following to the top of your Xamarin.iOS and/or Xamarin.Android .csproj file:

      <PropertyGroup>
        <RestoreProjectStyle>PackageReference</RestoreProjectStyle>
      </PropertyGroup>
    

    My current steps are:

    • Copy your packages.config as a backup
      • Use it as a reference when you re-add the packages on the last step
    • Manually remove all packages from the project (Xamarin.iOS or Xamarin.Android)
    • Edit the csproj and add the PackageReference
    • Re-add just the top-level packages

    Note: I do the manual package remove one-by-one via the IDE in order to properly update the project references. Also, when re-adding them after the PackageReference additional, the csproj is updated correctly (you can do this manually in the csproj text but it is a pain and easy to screwup).

    0 讨论(0)
提交回复
热议问题