locked
Visual Studio for Mac cannot build two Xamarin.Forms projects into a single solution RRS feed

  • Question

  • User132529 posted

    I just used latest Visual Studio for Mac. It's easy to reproduce 1. Create a XF project, then build, it's OK. 2. Create a solution folder and new the second XF project under that solution folder. 3. Make sure all files in the second XF project is in one folder. 4. Build the second project iOS or Droid failed, build PCL, OK,

    The error is different, sometimes is error XF001: Xamarin.Forms targets have been imported multiple times. Please check your project file and remove the duplicate import(s). Sometimes is MSbuild falied, no details

    here is the detail === Visual Studio Community 2017 for Mac ===

    Version 7.3.2 (build 12) Installation UUID: 57bfe2c6-725d-410d-b5f2-52b69d97c377 Runtime: Mono 5.4.1.7 (2017-06/e66d9abbb27) (64-bit) GTK+ 2.24.23 (Raleigh theme)

    Package version: 504010007
    

    === NuGet ===

    Version: 4.3.1.4445

    === .NET Core ===

    Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 2.0.0 1.1.1 1.0.4 SDK: /usr/local/share/dotnet/sdk/2.0.0/Sdks SDK Versions: 2.0.0 1.0.1 MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.1/lib/mono/msbuild/15.0/bin/Sdks

    === Xamarin.Profiler ===

    Version: 1.6.0 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

    === Apple Developer Tools ===

    Xcode 9.2 (13772) Build 9C40b

    === Xamarin.Android ===

    Version: 8.1.0.25 (Visual Studio Community) Android SDK: /Users/jesse/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 6.0 (API level 23) 7.0 (API level 24) 7.1 (API level 25) 8.0 (API level 26)

    SDK Tools Version: 25.2.5 SDK Platform Tools Version: 25.0.5 SDK Build Tools Version: 26.0.3

    Java SDK: /usr java version "1.8.0131" Java(TM) SE Runtime Environment (build 1.8.0131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)

    Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

    === Xamarin.iOS ===

    Version: 11.6.1.2 (Visual Studio Community) Hash: 6857dfcc Branch: xcode9.2 Build date: 2017-12-04 21:20:41-0500

    === Xamarin.Mac ===

    Version: 4.0.0.214 (Visual Studio Community)

    === Xamarin Inspector ===

    Version: 1.3.2 Hash: 461f09a Branch: 1.3-release Build date: Tue, 03 Oct 2017 18:26:57 GMT Client compatibility: 1

    === Build Information ===

    Release ID: 703020012 Git revision: 7d0c9d7ad46b125cf4b7bbf9532c0531b6433ce6 Build date: 2017-12-12 14:03:18-05 Xamarin addins: 6dddaa49fbecb2695fcdcd6b712eb269e288518c Build lane: monodevelop-lion-d15-5

    === Operating System ===

    Mac OS X 10.13.2 Darwin 17.3.0 Darwin Kernel Version 17.3.0 Thu Nov 9 18:09:22 PST 2017 root:xnu-4570.31.3~1/RELEASEX8664 x86_64

    === Enabled user installed addins ===

    NuGet Package Management Extensions 0.12.2 Internet of Things (IoT) development (Preview) 7.1

    Friday, December 15, 2017 4:03 AM

All replies

  • User18049 posted

    Does this still happen after closing and re-opening the solution? I hit the build failure, with no real MSBuild error information, on adding the new Xamarin.Forms project to an existing solution but on closing and re-opening the solution it seems OK. I was unable to reproduce any error about the Xamarin.Forms target being imported multiple times.

    Also do you have any errors in your IDE log when it fails?

    I did get a few internal errors logged in the IDE log - which probably caused the build to fail with the obscure internal build error message.

    Friday, December 15, 2017 3:16 PM
  • User132529 posted

    @mattward Thanks for your reply, yes, this solves a part of my problem.

    But if you change one project from them to .Net standard, you will get the error again.

    Monday, December 18, 2017 4:07 AM
  • User18049 posted

    Can you post the errors are in your IDE log after you reproduce the problem?

    Also which Xamarin.Forms project template are you using?

    Monday, December 18, 2017 11:04 AM
  • User132529 posted

    Blank Forms App template

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

    Monday, December 18, 2017 10:25 PM
  • User18049 posted

    I am interested in the errors in the IDE log (Help - Open Log Directory). Just want to confirm the error is the same as what I am seeing. Thanks.

    Monday, December 18, 2017 10:56 PM
  • User178955 posted

    I had the same problem: I've managed to resolve it by adding a new property <ExcludeRestorePackageImports>true</ExcludeRestorePackageImports> to the .NET Standart project csproj. I'm not really sure what it does but now my app can be built.

    Wednesday, December 20, 2017 9:05 AM
  • User132529 posted

    My solution is to delete this line in the second PCL project file.

    <Import Project="..\..\packages\Xamarin.Forms.2.5.0.121934\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.5.0.121934\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets')" />

    But I think this is a bug of VS for mac, @mattward

    Wednesday, December 20, 2017 10:16 PM
  • User18049 posted

    Yes, it is a bug. Would you be able to please post the IDE log after reproducing the error? Thanks.

    Wednesday, December 20, 2017 11:06 PM
  • User132529 posted

    https://www.dropbox.com/s/a80skfazogez68j/Ide.2017-12-20__15-54-27.log?dl=0

    Wednesday, December 20, 2017 11:21 PM
  • User18049 posted

    Thanks. That IDE log only seems to have a debugger error about being unable to find an executable. So the MSBuild failed error is no longer happening?

    I will see if I can repro the problem using the Blank Forms app project. Previously I was using the Forms app which creates a shared project.

    Wednesday, December 20, 2017 11:32 PM
  • User18049 posted

    Thanks. That IDE log only seems to have a debugger error about being unable to find an executable. So the MSBuild failed error is no longer happening?

    I will see if I can repro the problem using the Blank Forms app project. Previously I was using the Forms app which creates a shared project.

    Wednesday, December 20, 2017 11:32 PM
  • User176749 posted

    I am having this error in UWP application on VS2017 on Windows10. I cant figure out how to solve. I dont have any duplicated import tags for xamarin forms neither in pcl csproj file nor in uwp project file. how can I solve this?

    Monday, January 15, 2018 3:29 PM
  • User18049 posted

    Closing and re-opening the solution fixes the problem with two Xamarin.Forms projects are in the solution. Also it looks like this is fixed in Visual Studio for Mac 7.4 currently available on the alpha and beta channels.

    @batmaci - However you may be seeing a different error. It depends what is in your IDE log (Help - Open Log Directory).

    Monday, January 15, 2018 3:38 PM
  • User364601 posted

    @mattward I am seeing the same issue in Visual Studio for Mac v7.3.3. I saw this issue when trying to convert from a PCL library to .NET Standard in Options.

    I have attached a copy of the ide log file showing a fair number of issues.

    Is it possible to confirm whether this is the same issue. If so when it 7.4 likely to be release outside of beta? Also closing and re-opening the solution doesn't resolve my issue.

    Monday, January 15, 2018 10:35 PM
  • User18049 posted

    @bijington - Which error are you seeing? The problem I was seeing was the MSBuild failure with no other information - that seems to be fixed in Visual Studio for Mac 7.4. If you seeing the XF001: Xamarin.Forms targets have been imported multiple times. Please check your project file and remove the duplicate import(s). error then I would check your projects to see if the same version of Xamarin.Forms is used everywhere and there are not duplicate imports.

    Tuesday, January 16, 2018 9:08 AM
  • User364601 posted

    @mattward it is the XF001: Xamarin.Forms targets have been imported multiple times. Please check your project file and remove the duplicate import(s). issue I am seeing. I have gone through my project file multiple times and cannot find any duplicate imports for Xamarin.Forms.

    While both projects appeared to have the same Xamarin.Forms version there was an update so I have attempted to update it. I am unable to update to the latest in my PCL library as it gives the following error: Invalid restore input. Invalid target framework 'unsupported'. Something I will need to look in to when I get a chance

    Tuesday, January 16, 2018 9:16 AM
  • User18049 posted

    If you converted the PCL project to .NET Standard via the project options the project will be using a project.json. NuGet will generate two files that also import the Xamarin.Forms.props and Xamarin.Forms.targets: projectname.nuget.props and projectname.nuget.targets. If your project file that uses the project.json file also imports the Xamarin.Forms.targets then that may be the double import.

    I just reproduced that problem myself with VS Mac 7.3.3. I created a Xamarin.Forms Class Library (Multiplatform - Library) from the project template, then went into project options Build - General and converted the PCL to .NET Standard. Then tried to build the project. I see a build error Xamarin.Forms.2.5.0.121934/build/portable-win+net45+wp80+win81+wpa81/Xamarin.Forms.targets(3,3): Error XF001: Xamarin.Forms targets have been imported multiple times. Please check your project file and remove the duplicate import(s). (XF001). To fix this I edited the .csproj and removed the Xamarin.Forms.targets import from the file:

    <Import Project="..\packages\Xamarin.Forms.2.5.0.121934\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets" Condition="Exists('..\packages\Xamarin.Forms.2.5.0.121934\build\portable-win+net45+wp80+win81+wpa81\Xamarin.Forms.targets')" />

    Tuesday, January 16, 2018 9:41 AM
  • User364601 posted

    @mattward that makes sense now! Thank you! I was looking for duplicates within the same file not across multiple files within the same project (doh).

    Tuesday, January 16, 2018 9:51 AM
  • User287155 posted

    This is incredibly annoying ... Ha when are they going to fix this problem? I don't think we should have to be modifying these files.

    Tuesday, October 23, 2018 12:43 AM