Forum Xamarin.Forms

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

How can I port to Xamarin.Forms .NET Core 3.1 to .NET 5

kavi93kavi93 Member ✭✭
edited November 2020 in Xamarin.Forms

When try this command try-convert.exe -w . I getting following error.

Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "C:\Program Files\dotnet\sdk\5.0.100\Xamarin\Android\Xamarin.Android.CSharp.targets" was not found. Confirm that the expression in the Import declaration "C:\Program Files\dotnet\sdk\5.0.100\Xamarin\Android\Xamarin.Android.CSharp.targets" is correct, and that the file exists on disk.  D:\VSProjects\SkyRacingApp\SkyRacing\SkyRacing.Android\SkyRacing.Android.csproj
   at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
   at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1,T2](IElementLocation elementLocation, String resourceName, T1 arg0, T2 arg1)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpression(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, Boolean throwOnFileNotExistsError, List`1& imports)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError)
   at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
   at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
   at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate()
   at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(IEvaluatorData`4 data, ProjectRootElement root, ProjectLoadSettings loadSettings, Int32 maxNodeCount, PropertyDictionary`1 environmentProperties, ILoggingService loggingService, IItemFactory`2 itemFactory, IToolsetProvider toolsetProvider, ProjectRootElementCacheBase projectRootElementCache, BuildEventContext buildEventContext, ISdkResolverService sdkResolverService, Int32 submissionId, EvaluationContext evaluationContext, Boolean interactive)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.ReevaluateIfNecessary(EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project.ProjectImpl.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
   at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
   at MSBuild.Abstractions.UnconfiguredProject.LoadProjects(ProjectCollection collection, ImmutableDictionary`2 globalProperties, String projectFilePath) in /_/src/MSBuild.Abstractions/UnconfiguredProject.cs:line 28
   at MSBuild.Abstractions.MSBuildConversionWorkspace..ctor(ImmutableArray`1 paths, Boolean noBackup, String tfm, Boolean keepCurrentTFMs) in /_/src/MSBuild.Abstractions/MSBuildConversionWorkspace.cs:line 44
   at MSBuild.Abstractions.MSBuildConversionWorkspaceLoader.LoadWorkspace(String path, Boolean noBackup, String tfm, Boolean keepCurrentTFMs) in /_/src/MSBuild.Abstractions/MSBuildConversionWorkspaceLoader.cs:line 45
   at MSBuild.Conversion.Program.Run(String project, String workspace, String msbuildPath, String tfm, Boolean preview, Boolean diffOnly, Boolean noBackup, Boolean keepCurrentTfms) in /_/src/try-convert/Program.cs:line 102

I cannot find the Xamarin directory inside C:\Program Files\dotnet\sdk\5.0.100. I've already installed .NET 5 sdk from here: https://dotnet.microsoft.com/download/dotnet/5.0 , and updated Visual Studio to new version too, anything else I need to install?

Answers

  • jezhjezh Member, Xamarin Team Xamurai

    For xamarin forms, we use .NET Standard library . We don't use .NET Core.

    For more details, you can check this article:Building Xamarin.Forms Apps with .NET Standard

  • Amar_BaitAmar_Bait DZMember ✭✭✭✭✭
    edited November 2020

    Tldr: try-convert.exe does not work with Xamarin (since Xamarin does not run on .NET Core/.NET 5.0)

    Xamarin.Android/iOS projects use Mono, not .NET Core/.NET 5.
    Xamarin.Forms shared project uses .NET Standard 2.0/2.1.

    Next versions of Xamarin.Android/iOS and Xamarin.Forms (MAUI 1.0) will use .NET 6.0, next year.

Sign In or Register to comment.