How to Set Up Xamarin.Forms for MacOS Sierra?

这一生的挚爱 提交于 2019-12-11 17:21:23

问题


Visual Studio seems to be having a hard time starting up, so I'm wondering if there's anything wrong in my setting it up. I'm currently using:

  • macOS Sierra, version 10.12.6
  • Visual Studio (VS) for Mac (Community edition), version 7.3.2 (build 12)

Setting up New Solution:

A (New Project):

  1. select Multiplatform App
  2. under Xamarin.Forms, select Blank Forms App (C#)
  3. select Next

B (Configure your Blank Forms App, part 1):

  1. App Name: ABCD
  2. Organizer Identifier: com.WXYZ
  3. Target Platforms: select both Android and iOS
  4. Shared Code: select Use Portable Class Library and Use XAML for user interface files
  5. select Next

C (Configure your Blank Forms App, part 2):

  1. Project Name: ABCD
  2. Solution Name: ABCD
  3. Location: [choose location], select Create a project directory within the solution directory.
  4. Version Control: select nothing
  5. Xamarin Test Cloud: select nothing
  6. select Create

Immediately, VS begins the Adding packages... process. After it's done, the 3 Packages folders have a variety of Xamarin-related files, one of which they all have in common: Xamarin.Forms.

Just as a test, I right-click on ABCD solution folder and select Clean ABCD. Immediately, I get hit with this:

Error XF001: Xamarin.Forms targets have been imported multiple times. Please check your project file and remove the duplicate import(s). (XF001) (ABCD)

Why is this happening? I've tried separately deleting each of the Xamarin.Forms file in each of the aforementioned 3 Packages folders, but that did nothing good.

Right-clicking on the error message and selecting Show Error Reference literally just takes me to a Google Search result page for the search term "XF001", which helps 0%.

What am I doing wrong?


回答1:


I have encountered this as well. It seems like a bug in the current 'New Project' templates, at least in Visual Studio for Mac.

Go into the folder where the csproj file of your shared library is. edit it with Notepad or similar and find the <import> node(s) at the bottom. There should be one which has something relatable to Xamarin in it. Remove this import node, save it and open/reload your solution.




回答2:


Nuget might generate (for some reason) .nuget.targets and .nuget.props files in the project directory containing Import statements for Xamarin.Forms in addition to the same Import statements in the project file (<project>.csproj).

Backup the .nuget.targets and/or .nuget.props files and try removing the .nuget.targets and .nuget.props files from the project directory.



来源:https://stackoverflow.com/questions/48056393/how-to-set-up-xamarin-forms-for-macos-sierra

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!