问题
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):
- select Multiplatform App
- under Xamarin.Forms, select Blank Forms App (C#)
- select Next
B (Configure your Blank Forms App, part 1):
- App Name: ABCD
- Organizer Identifier: com.WXYZ
- Target Platforms: select both Android and iOS
- Shared Code: select Use Portable Class Library and Use XAML for user interface files
- select Next
C (Configure your Blank Forms App, part 2):
- Project Name: ABCD
- Solution Name: ABCD
- Location: [choose location], select Create a project directory within the solution directory.
- Version Control: select nothing
- Xamarin Test Cloud: select nothing
- 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