Xamarin bundle mono with app fails, because .net Framework(folder) missing

SnakepitBeanSnakepitBean USMember
edited November 2015 in Xamarin.iOS

Hi,

I have a MonoMac project(and related projects in the sln, shared from another solution) which works perfectly fine on both Debug & Release & Build server.
The Target Frameworks on projects are ".Net Framework 4.5.1". Note its not "Mono/.Net 4.5".
Now when I select "bundle mono with the app" option in my MonoMac project, it fails to build.
" Error MM1403: Directory /Library/Frameworks/Mono.framework/Versions/4.2.1/lib/mono/4.5.1 could not be found. Target framework '4.5.1' is unusable to package the application. (MM1403) "

Indeed the folder 4.5.1 is missing. I see only folders 2.0, 3.5, 4.0 & 4.5.
I installed the latest mono from Nov 17th 2015 to see if it creates a 4.5.1 folder, which it did not.
How can I go about resolving this issue?

Side Note - If I change the project target framework to "Mono/.Net 4.5"(all projects), it builds, because that folder is present in the machine.
But then the app will not launch, so that doesn't help.
Also I cannot just change all projects to Mono/.Net 4.5, since some of them are shared.
If .net 4.5.1(or folder) is missing from my system, then how come it runs perfectly when I run the project from Xamarin?
And why is it not able to bundle the dlls from wherever Xamarin uses to run the app?

Any help?
Xamarin Studio V5.10(Build 871) on Mac 10.10.4

Answers

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    So, this may be a bug in our packager (mmp), or a bug in XS to show those options, I'm not sure. We use that to select which folder in /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/ to pick.

    You may be about to hack around this behavior by adding a symbolic link:

        sudo ln -s /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5 /Library/Frameworks/Mono.framework/Versions/Current/lib/mono/4.5.1
    

    But this will break every mono upgrade, so at best it is a temporary work around.

    What output do you get when you launch the app? In theory 4.5 and 4.5.1 should be compatible, so I don't know of a reason currently why you shouldn't be able to use 4.5 and consume 4.5.1 assemblies.

  • SnakepitBeanSnakepitBean USMember
    edited November 2015

    Hi Chris,
    Thanks for the response. This work-around works great!
    Having said that, do you think there is going to be a fix on the mmp OR XamarinStudio for this issue?
    I ask that because, each of our dev would have to run this work around, and also our build servers.
    And would have to run these again when we upgrade versions next.
    Is there a way to raise a ticket on my subscription level, and get this fixed?
    Please let me know. Thanks again!

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    So, filing a support ticket doesn't necessarily ensure that it gets fixed, but it would likely ensure you'd get your question answered (but I answered it here anyway). In either case, http://support.xamarin.com is where you go.

    At some point, yes it should be fixed, I don't disagree. Could you please answer my last question though:

    What output do you get when you launch the app? In theory 4.5 and 4.5.1 should be compatible, so I don't know of a reason currently why you shouldn't be able to use 4.5 and consume 4.5.1 assemblies.

  • SnakepitBeanSnakepitBean USMember
    edited November 2015

    Sure. The output is a .app file, and it is a statusbar app. The project is NOT using the new Unified framework.
    And I dont have an issue running the app anywhere, even though the project is pointing at ".Net Framework 4.5.1" and mono only has versions folders upto 4.5.
    The issue I'm facing is happening, when I check the option to bundle mono along with the app file. It doesn't compile.

    Scenario 1 -

    Project setting - .Net Framework 4.5.1
    Mac Build > Include mono with app > No linker enabled
    Result is a Compile error -
    " Error MM1403: Directory /Library/Frameworks/Mono.framework/Versions/4.2.1/lib/mono/4.5.1 could not be found. Target framework '4.5.1' is unusable to package the application. (MM1403) "

    Scenario 2 -

    Project setting - Change .Net Framework 4.5.1 to "Mono/.Net 4.5"
    Mac Build > Include mono with app > No linker enabled
    Result - Compilation works. Bouncy icon on tray & App launches as expected.

    Scenario 3 -

    Project setting - .Net Framework 4.5.1
    Mac Build > Include mono with app > No linker enabled
    Applied the work around you provided - "sudo ln -s....." which created a "4.5.1" shortcut as seen in the attachment.
    Result - Compilation works. Bouncy icon on tray & App launches as expected.

    Third scenario works best for us, because we dont have to step back a version, since we have shared projects from other projects. And the bundling works as expected, and the app works too.
    Here the bundle process still works the same - it looks for mono dlls in 4.5.1 folder(selected from project settings), but since the shortcut is available it picks the dlls from 4.5 (which was the expected behavior).

    Hope that answers your question. Please reply back for any more details.
    Thanks!

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    My question is on Scenario 2. If you change the top level executable XM project to 4.5 and depends on the 4.5.1 libraries what happens (compile error? runtime?).

    In theory, I don't see why 4.5 and 4.5.1 can't play nice mixed.

  • If I change the top level executable XM project to 4.5 back from 4.5.1, it compiles fine. No runtime error as well.
    It is also possible we don't use any 4.5.1 dependent libraries in our code (nothing that I know of).

    But like I said the overall issue was not because 4.5 was not playing well with 4.5.1.
    The issue was that, while trying to bundle mono within the app file (something that we were trying out newly), it was looking for a 4.5.1 folder, and there was only a 4.5 folder available in the machine.

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    I think we're missing each other here.

    • I agree that the 4.5.1 option should either not exist in the dialog or do the right thing.
    • Ignoring that for a minute, it sounds like you can swap just the XM version to 4.5 instead of 4.5.1 in just the final exe project and have things work.
    • If that is true, why do you need the symbolic link. Can't you just swap just the XM project to 4.5.1 in just the final exe project and consume the libraries as is. If not, what's the issue?
  • Hi Chris,

    Sorry about the delay in response. Was out on vacation.
    In theory, what you suggested should work. It makes sense.
    However when I tried changing version of the main XamMac project to 4.5, almost immediately the references to my other projects showed a red 'X' error icon on the Solution explorer.
    Also when I try to compile - I got errors, understandable - because the supporting projects are not referenced anymore.
    When I tried to re-add the projects from Edit references window, i see "Incompatible target framework: .NetFramework, Version=v4.5.1" error.
    Please check the attached screen shot.
    Not sure why, but would appreciate any thoughts on this.

    Thanks.

    Note -
    VS 2013 lets you compile projects from different versions. But if the main project is say on .net v4.5, it will let other projects from lower version frameworks compile succesfully - 3.5 or 4.0, but not higher, say 4.5.1. Not sure if it is related, but just thought I'd mention it here.

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    Oh i see. 4.5.1 can reference 4.5 but not other way around?

    In either case, I now agree that this is a bug and should be fixed in mmp.

    https://bugzilla.xamarin.com/show_bug.cgi?id=36392

Sign In or Register to comment.