user2323030
user2323030

Reputation: 1221

How to Set Up Xamarin.Forms for MacOS Sierra?

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:

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?

Upvotes: 0

Views: 672

Answers (2)

Ben
Ben

Reputation: 2985

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.

Upvotes: 1

Gerald Versluis
Gerald Versluis

Reputation: 33993

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.

Upvotes: 1

Related Questions