Visual Studio for Mac does not get past "Add packages" - macos

I am trying out Xamarin Forms on Visual Studio for Mac.
When I create a new project, I see VS is trying to add packages to the solution, but every single time- it fails at the same place...
Here is the Package Console output:
https://drive.google.com/open?id=1-KfdWC2hub4YuEOHfJ_LICL86o6zkecytmMAi0emDeQ
On this new project, after the package installer fails, it always fails to build with the default assets:
Is it possible other dev environments are affecting Visual Studio?
Is there a more stable way I can use Xamarin forms on a Mac?
Thanks in advance!

One of the errors I see in your Package Console is:
Could not install package 'Xamarin.Android.Support.v4 23.3.0'. You are
trying to install this package into a project that targets
'MonoAndroid,Version=v2.3', but the package does not contain any
assembly references or content files that are compatible with that
framework.
NuGet looks at your project's target framework and version to see if the NuGet packages are compatible. As far as NuGet is aware your project is targeting MonoAndroid version 2.3. Check what you have selected as the Compile using Android version in the project properties and ensure that it's compatible with the package you want to add.
Also, a "more stable" way to use Xamarin Forms on a Mac is not available unless you want to try Xamarin Studio but that is almost the same as Visual Studio for Mac (which is based on it).

Related

TypeScript version mismatch in Visual Studio 2019

I am thoroughly confused by Typescript versioning as it relates to Visual Studio 2019. I have a .NET Core 2.2.x project which utilizes Typescript. When I edit any .ts file, I get the following warning (in the error list):
Your project is built using TypeScript 3.4, but the TypeScript language service version currently in use by Visual Studio is 3.4.3. Your project may be using TypeScript language features that will result in errors when compiling with this version of the TypeScript compiler. To remove this warning, install the TypeScript 3.4.3 SDK or update the TypeScript version in your project's properties.
It claims that my project is built using TypeScript 3.4, but package.json specifically lists "typescript": "3.4.3".
Then it asks to install TypeScript SDK 3.4.3, which I have from here. I also npm install -g typescript previously, so running tsc -v yields Version 3.4.3.
What am I missing?
I had a similar problem as you describe but in the Task Runner Explorer.
Assumptions: TypeScript is should be in your PATH variables (you can check by running 'tsc -v' from a normal command prompt.
Since quite a while, Visual Studio allows you to choose the TypeScript version to use on a per-project basis (right-click project => Properties => tab 'Typescript Build'). Here you could choose an officially installed version but also 'Use latest available'.
In Visual Studio Options you can specify the locations and order in which 'External Web Tools' are used when building web projects using 3rd party tools. In that list, you will probably find an item '$(PATH)'. I moved it to the top of the list, which makes the globally installed TypeScript version the first to be found when searching for it.
I hope this applies for your situation as well.
This may have gotten easier since the original answer.
Now you can just install NuGet package Microsoft.TypeScript.MSBuild.
Then you don't need to install the SDK separately and it is recommended by Microsoft to use NuGet or npm:
https://learn.microsoft.com/en-us/visualstudio/javascript/javascript-in-vs-2019?view=vs-2019
In the project Properties > Typescript Build tab, the Typescript version will change to n.n (NuGet) and will be grayed out. Now if you work on a team, all team members will be certain to have the same version for this project! Cool!

.Net Core 1.1.0 NuGet packages fail to install in Visual Studio Mac

I'm playing around with a ASPNet.Core 1.1.0 application in Visual Studio Mac Preview and have problems updating/installing NuGet packages.
If I try to update eg. Microsoft.AspNetCore.Diagnostics from 1.0.0 to 1.1.0 it fails the download and removed the package completely. I then have to download and install the package for 1.0.0 again. Same goes for Microsoft.AspNetCore.Server.Kestrel.
Microsoft.EntityFrameworkCore I'm not able to install in any version.
Heres the exception output: https://gist.github.com/anonymous/52ceb28b8d9781835b226bcbe9d04d58
I know everything is right out of the oven, but was wondering if other people have experienced the same issues and know of a workaround/solution.
For everyone else having similar problems, here's a walk-through:
First install .NET Core 1.1.0: https://www.microsoft.com/net/core#macos
The official .NET Core 1.1.0 installer (as of when this is written) includes the .NET Core SDK 1.0.0 Preview 2.
You will need .NET Core SDK 1.0.0 Preview 3. Download it here: https://github.com/dotnet/core/blob/master/release-notes/preview3-download.md
Create a new project in Visual Studio Mac
Close the project
Open up project/src/myapp/myapp.csproj and change "netcoreapp1.0" to "netcoreapp1.1". Save and close the file.
<TargetFramework>netcoreapp1.1</TargetFramework>
Open your solution in Visual Studio Mac and compile it.
Now you will be able to update your NuGet packages to newest versions.
Should you run into problems, do a "dotnet restore" when standing in /project/src/myapp/
I reached out on Twitter and got a response from Mikayla Hutchinson, Xamarin PM at Microsoft. Check out the conversation on Twitter here.
certain NuGet packages fail to restore if they're not already in
your local cache - see https://developer.xamarin.com/releases/vs-mac/preview/vs-mac-preview1/#Known_Issues
as a workaround, you can use dotnet restore on the command-line,
which will restore and cache them
I hope this helps.
Try to change *.csproject file manually to
<TargetFramework>netcoreapp1.1</TargetFramework>
UPDATE
#egeek So, finally, I think I found some trick. I tried to add Swashbuckle Nuget package, but it failed. Then, when Visual Studio start to adding Swashbuckle, I click Forece Quit from Visual studio before the operation is complete. In *.csproj I see:
<PackageReference Include="Swashbuckle">
<Version>6.0.0-beta902</Version>
</PackageReference>
And when I again open Visual studio, click "Restore" on "Packages" folder.
Finally it not fail and added Swashbuckle correctly.
Try upgrading your nuget latest version for core 1.1 https://dist.nuget.org/index.html will resolve the issue.

How use Roslyn Scripting in OSX with F#?

I'm getting confusing with the pletora of assemblies that I get from nuget related to Roslyn. I have last version of xamarin with .NET 4.5 profile. I wish to use the scripting part of Roslyn. But don't found how setup the project.
What si the package from nuget I need to download? Is my impression, but the names of the namespaces have changed? Because the tutorial I have found using C# not match what I have get from nuget
With the last version of Visual Studio for Mac, I can finally create .NET Standard Library and reference the Microsoft.CodeAnalysis NUGET packages.

Adding System.Data.SQLite through NuGet doesn't add a reference to the project

I'm trying to make a very simple Xamarin.Forms test application to explore some features of the System.Data.SQLite package (namely encryption). However, I can't seem to get Visual Studio 2012 to add a reference to the package to the project.
Here are the steps I am taking:
Created a new Xamarin.Forms Portable blank app.
Right-click on TestApp (core project) and select Manage NuGet Packages
Search for "sqlite"
Install the "System.Data.SQLite (x86/x64)" package. (This package is version 1.0.97.0 and it is described as "the official SQLite database engine for both x86 and x64 along with the ADO.NET provider.")
According to NuGet, the package was successfully installed.
However, I cannot see the reference added under my project's "References" folder, and I also cannot write "using System.Data.SQLite" without errors ("cannot resolve symbol 'Data'"). Does anyone have any idea why this is happening?
On a side note, I can follow the exact same process described above except instead of creating a Xamarin.Forms Portable blank app, I choose a regular C# console app. This allows me to install the NuGet package fine and it shows up in references as expected.
Posting an update to share what I've learned.
So as Jason sort of alluded to in his answer, the reason I was not able to reference the package in my Xamarin.Forms project is because Xamarin.Forms is, by definition, a PCL project. It's meant to work on all platforms. The package I was referring to in my question is not a PCL, which means that anything in the package that is platform dependent is inaccessable (which is basically the entire package). The SQLite.Net-PCL package is basically the same thing as System.Data.SQLite, but in PCL form, which means it is compatible for use in a Xamarin.Forms project.
Following this logic, it makes sense that I was able to access System.Data.SQLite from a console project, since a console project is not a PCL project and it targets a specific platform.
For PCL projects, use SQLite.Net-PCL.

Adding MOQ to a .NET 4.0 project is not possible

I want to add MOQ .net library to a .NET 4.0 project. I get an error message that I should convert the project to something smaller than 4.0. I need to use .NET 4.0 also because of other project dependencies.
How can I make MOQ work with a .NET 4.0 project in VS2010 ?
Make sure you have NuGet package manager installed (Tools/Extension Manager).
Right click on Solution Explorer/References, choose Manage NuGet Packages.
Type Moq in the search box.
Install and enjoy.
The latest version from Google Code (http://code.google.com/p/moq/), works in a .Net 4.0 project. I would just download the dll again.
Here is the download link: http://code.google.com/p/moq/downloads/detail?name=Moq.4.0.10827.Final.zip
The zip file at that location contains a .Net 4 folder. Use the dll : Moq.dll from the NET40 folder and everthing will work fine. Just do a normal Add Reference on the project.
I would check the version number and the Runtime veseion of the assembly you are trying to use. It should say:
Runtime Version: v4.0.20926
Version: 4.0.10827.0
For the sake of completeness, it may be worth pointing out that it is also possible to use the Visual Studio command line package manager tool:
1) Open the console in VS
View >> Other Windows >> Package Manager Console
2) Install Moq
Type Install-Package Moq at the prompt
Note: If your tests are in a separate project, make sure that you select that project in the project dropdown.
This will install the latest package available in NuGet, which should address your compatibility issue. See http://nuget.org/packages/moq.
Watch out that you're using .NET 4, rather than the .NET 4 Client Profile as your Target Framework. I had the same issue and that was the cause for me.

Resources