xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.63k stars 1.88k forks source link

Visual Studio 2017 and Xamarin Forms Issues #3236

Closed NMansuriET closed 6 years ago

NMansuriET commented 6 years ago

Description

If i try to create a Xamarin.Forms (3.1) project in Visual Studio 2017, it fails with below issues.

Severity Code Description Project File Line Suppression State Error MSB4062 The "Xamarin.Forms.Build.Tasks.XamlGTask" task could not be loaded from the assembly C:\Users\nmansuri.nuget\packages\xamarin.forms\3.0.0.561731\build\netstandard2.0\Xamarin.Forms.Build.Tasks.dll. Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. July7App C:\Users\nmansuri.nuget\packages\xamarin.forms\3.0.0.561731\build\netstandard2.0\Xamarin.Forms.targets 75

Severity Code Description Project File Line Suppression State Error MSB4062 The "Xamarin.Forms.Build.Tasks.GetTasksAbi" task could not be loaded from the assembly C:\Users\nmansuri.nuget\packages\xamarin.forms\3.1.0.583944\build\netstandard2.0\Xamarin.Forms.Build.Tasks.dll. Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. July7App C:\Users\nmansuri.nuget\packages\xamarin.forms\3.1.0.583944\build\netstandard2.0\Xamarin.Forms.targets 36

Another observation is the warning symbol appearing on the Dependencies folders in the shared library project. I dont understand why it appears.

Steps to Reproduce

  1. Create a new Blank Forms Project - choose only android and ios target projects and code sharing strategy is set to .NET standard
  2. Without making any changes to the default structure, Build or clean solution
  3. the above mentioned errors are thrown

Expected Behavior

The solution should be built successfully

Actual Behavior

Basic Information

Screenshots

vsxamarinformsissue

Reproduction Link

NMansuriET commented 6 years ago

I tried the below steps:

  1. Downgraded the Xamarin Forms version for all projects from 3.0 to 2.5
  2. Closed studio and manually deleted bin and obj folder under each project
  3. Opened VS and the rebuilt the solution. SUCCESSFULLY rebuild all project!!

I cannot build Forms app with 3.x version on VS 2017 professional.

VladislavAntonyuk commented 6 years ago

Delete all folders in C:\Users\nmansuri.nuget\packages

NMansuriET commented 6 years ago

deleting packages is not working..

I have observed the yellow warning ticks on the dependencies folder in the shared library. If the Forms version is 3.x, i get this warning ticks else not. I think this is the root cause of my problem. I have not configured the environment properly.

How the dev environment should be configured to use Xamarin Forms in VS2017 if: 1) Windows OS is 10 2) Which .NET framework needs to be installed? Is there any compatiblity issues of Xamarin Forms with the .NET framework? 3) The components that i opted while installing VS2017 : a) Mobile Development with .NET b) .NET desktop development 4) the .NET runtime and frameworks installed are: dotnetframeworks

pauldipietro commented 6 years ago

Please install .NET Framework 4.7.1 if it isn't and see if that helps your issue.

NMansuriET commented 6 years ago

How do i install 4.7.1? Its not under the modify list. Any pointers on how to install it externally?

NMansuriET commented 6 years ago

Is Xamarin forms 3.x compatible with .Net Standard 2.0?

pauldipietro commented 6 years ago

Here is a page regarding the 4.7.1 release; I would suggest installing that, doing a full deletion of bin/obj folders along with a clean and rebuild of your project and report back. If it still does not work, uploading a solution that fails on your end can let us compare.

NMansuriET commented 6 years ago

I could not install 4.7.1. 471blocked

I have uploaded the source code https://github.com/NMansuriET/XamarinFormsBuildIssues

NMansuriET commented 6 years ago

Alright...after 5 days of frustration..i got it!

Forms 3.x will only work when you have .Net Framework 4.7. In windows 10 Pro, you can get .net Framework 4.7 only when you have the latest updates.

I first upgraded my windows 10 Pro from 1509 to 1803. After that i get option to modify my VS2017 to add .Net Framework 4.7

Steps to make Xamarin Forms 3.1 work with VS2017 .net standard 2.0

1) Update Windows 10 OS to a version compatible enough to get .NET Framework 4.7 2) Update VS 2017 and include .NET Framework 4.7

KyleLJohnson commented 6 years ago

Installing .net framework 4.7 didn't work for me.

praveenkrjha commented 6 years ago

Installing .NET framework 4.7.2 resolved this issue. Anyone else having this issue should upgrade .NET framework version to 4.7.2