How to downgrade Visual Studio for Mac?

I need to downgrade from 7.2 to 7.1.5.2
Transitive project.json dependencies are broken in 7.2

Best Answer

Answers

  • mattwardmattward GBMember Xamurai

    You should be able to get previous versions from the account page.

    What is the problem with transitive project.json dependencies in VS Mac 7.2?

  • JonathanDibbleJonathanDibble GBMember ✭✭

    @mattward From what I can see the account page only has Xamarin Studio, not Visual Studio for Mac. @RobLander Did you find the installation you needed?

  • JonathanDibbleJonathanDibble GBMember ✭✭
    edited October 2017

    Thanks @mattward

  • RobLanderRobLander GBMember ✭✭

    Thanks @mattward.

    About regression:

    • I have portable project with project.json file referencing Xamarin.Forms
    • I have iOS project with "empty" project.json file, that references portable project
    • In VS 7.1 iOS compiles fine because Xamarin.Forms dependency is transitioned to iOS project
    • In VS 7.2 I have tonns of "The type or namespace 'Xamarin' could not be found" errors
  • RobLanderRobLander GBMember ✭✭

    I've also tried to downgrade Xamarin.iOS and Mononpackages leaving VS 7.2 but that doesn't help. So it seems like it is VS related.

  • mattwardmattward GBMember Xamurai

    Looks like something has changed in NuGet 4.3 maybe. I created a new Xamarin.Forms project using VS Mac 7.2, then uninstalled the Xamarin.Forms NuGet package and added a project.json file to the PCL project (also removed the :

    {
      "dependencies": {
        "Xamarin.Forms": "2.4.0.280"
      },
      "frameworks": {
        ".NETPortable,Version=v4.5,Profile=Profile111": {}
      }
    }
    

    Then uninstalled the NuGet package from the iOS project and added a project.json file:

    {
        "frameworks": {
            "xamarin.ios10": {
                "imports": "portable-net45+win81+wp80+wpa81"
            }
        },
        "runtimes": {"win-x86" : {} }
    }
    
    

    Then reloaded the solution. The build fails in VS Mac 7.2 due to missing Xamarin.Forms types but works in VS Mac 7.1. The problem seems to be that the generated project.lock.json file does not have any Xamarin.Forms information when the NuGet restore is run using VS Mac 7.2. The main difference between VS Mac 7.1 and 7.2 is that NuGet was updated from 4.0 to 4.3.1.

    However using NuGet.exe 4.3.0 from the command line and running a restore, or using msbuild /t:restore, both seem to generated project.lock.json files with Xamarin.Forms information in them. Just VS Mac 7.2 does not.

    A potential workaround here would be to disable automatic package restore and run the restore outside VS Mac using msbuild /t:restore or nuget.exe.

  • RobLanderRobLander GBMember ✭✭

    So, it's a some kind of regression in newer nuget. Is it going to be fixed in Visual Studio for Mac updates?

  • mattwardmattward GBMember Xamurai

    Looks like a bug in VS for Mac. On upgrading to a more recent NuGet version some code in VS for Mac was removed due to a restructuring of various classes in NuGet itself. So it looks like project reference information is not being correctly setup when a restore is happening. I believe this then causes the transitively referenced NuGet packages to not be added to the project.lock.json. The lock file is also missing project references.

  • mattwardmattward GBMember Xamurai

    @RobLander - I have created a patch NuGet addin dll that should fix the problem with project.json files for VS Mac 7.2. You can download it from GitHub.

    Download that MonoDevelop.PackageManagement.dll file from GitHub. You may need to unblock it:

    xattr -d -r com.apple.quarantine MonoDevelop.PackageManagement.dll
    

    Then you can replace the existing NuGet addin .dll. I tested this locally by doing the following:

    // Make backup of NuGet addin .dll

    cp /Applications/Visual\ Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.dll /Applications/Visual\ Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.dll-backup
    

    // Replace existing NuGet addin .dll with new one.

    cp MonoDevelop.PackageManagement.dll /Applications/Visual\ Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.PackageManagement/MonoDevelop.PackageManagement.dll 
    

    Then the iOS project I was using for testing was building successfully and the project.lock.json file had the expected project references.

  • RobLanderRobLander GBMember ✭✭

    Btw maybe 15.4.2 service release contains this fix?

  • mattwardmattward GBMember Xamurai

    @RobLander - A fix will be in Visual Studio for Mac 7.3 at some point, not released currently. There is no fix for VS Mac 7.2 apart from using the patched binaries I linked to.

  • RonanA.7363RonanA.7363 IEMember ✭✭

    I updated to version 7.6.11 and it broke my project. I contacted support via visualstudio.com and was told there is no way to downgrade VS for MAC now. I'm posting here in the hopes that someone can point me to a repo or link somewhere to previous VS for mac versions?

  • mattwardmattward GBMember Xamurai

    @RonanA.7363 How did it break your project?

  • RonanA.7363RonanA.7363 IEMember ✭✭

    @mattward In fairness, it didn't break the project. I can still build it, I just can't deploy it to simulator or device. The options (Project > Configuration > Device) that are usually there are disabled. If I set the start up project to the android project, the options are populated and work.
    If i then use the drop down to change project from android to iOS, the application crashes with the message:

    "A fatal error has occurred
    Details of this error have been automatically sent to Microsoft for analysis. Visual Studio will now close."

    I've tried updating xcode and then opening xcode and it installed some extensions. I restarted the machine but no change. Resintalled VS For mac and no change.

    I tried creating a new Xamarin Forms project and the same issues as my own project.

    Xcode version: 10.0 (10A255)

    If you have any ideas, I'm definitively willing to try it as right now I have no way to test my project.

  • mattwardmattward GBMember Xamurai

    Can you attach the IDE log after reproducing the error? Thanks.

  • RonanA.7363RonanA.7363 IEMember ✭✭

    I've pulled this out of the logs that seems to be the problem:

    FATAL ERROR [2018-11-09 09:59:38Z]: Visual Studio failed to start. Some of the assemblies required to run Visual Studio (for example gtk-sharp)may not be properly installed in the GAC.
    System.InvalidOperationException: Failed to compare two elements in the array. ---> System.ArgumentOutOfRangeException: Length cannot be less than zero.
    Parameter name: length
    at System.String.Substring (System.Int32 startIndex, System.Int32 length) [0x00087] in /Users/builder/jenkins/workspace/build-package-osx-mono/2018-02/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/string.cs:1257
    at MonoDevelop.IPhone.IPhoneSimulatorExecutionTargetGroup.ParseIPhone (System.String name, System.String& device, System.Int32& version, System.String& subversion, MonoDevelop.IPhone.IPhoneSimulatorExecutionTargetGroup+IPhoneDeviceType& type) [0x00022] in /Users/vsts/agent/2.141.1/work/1/s/md-addins/MonoDevelop.IPhone/MonoDevelop.IPhone/Execution/IPhoneSimulatorExecutionTarget.cs:190

    In case I'm wrong, I'm attached the full log

  • mattwardmattward GBMember Xamurai

    The crash looks like it is the same as that reported on the developer community site. This bug is fixed in Visual Studio for Mac 7.7.0.1552. There is also a workaround mentioned in the developer community forum post. I believe the problem is that more recent versions of Xcode one of the simulators is 'X' which breaks Visual Studio for Mac. As far as I am aware downgrading Visual Studio for Mac will not help in this case. A workaround is to rename the simulators in Xcode so that no iOS simulator name begins with a number (i.e. 0-9) or the letter X or S.

  • RonanA.7363RonanA.7363 IEMember ✭✭

    @mattward spot on sir. well played

    I had a custom simulator set up called "11.4 iPhone 5". Once i renamed that to "iPhone 5 11.4", everything worked.

    Thanks very much for the help

Sign In or Register to comment.