xamarin / Xamarin.Forms

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

Error CS0012 when building against v3 #2564

Closed nickrandolph closed 6 years ago

nickrandolph commented 6 years ago

Description

Upgrading MvvmCross to v3 of XF we ran into issue where we're seeing the following error. error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. MvvmCross is multi-targeted and I suspect that this is related to when it's building the Android target

Steps to Reproduce

  1. Grab the branch of MvvmCross referenced in this PR https://github.com/MvvmCross/MvvmCross/pull/2831
  2. Attempt to build and run

Expected Behavior

Should build with no errors

Actual Behavior

~117 errors similar to: error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.

Basic Information

---------------------------------- Full VS Info -----------------------------------------------------

Microsoft Visual Studio Professional 2017 Preview Version 15.7.0 Preview 5.0 VisualStudio.15.Preview/15.7.0-pre.5.0+27625.0 Microsoft .NET Framework Version 4.7.02556

Installed Version: Professional

Application Insights Tools for Visual Studio Package 8.12.10405.1 Application Insights Tools for Visual Studio

ASP.NET and Web Tools 2017 15.0.40422.0 ASP.NET and Web Tools 2017

ASP.NET Core Razor Language Services 15.7.31476 Provides languages services for ASP.NET Core Razor.

ASP.NET Web Frameworks and Tools 2017 5.2.60419.0 For additional information, visit https://www.asp.net/

Azure App Service Tools v3.0.0 15.0.40424.0 Azure App Service Tools v3.0.0

Azure Data Lake Node 1.0 This package contains the Data Lake integration nodes for Server Explorer.

Azure Data Lake Tools for Visual Studio 2.3.3000.4 Microsoft Azure Data Lake Tools for Visual Studio

Azure Functions and Web Jobs Tools 15.0.40424.0 Azure Functions and Web Jobs Tools

Azure Stream Analytics Tools for Visual Studio 2.3.3000.4 Microsoft Azure Stream Analytics Tools for Visual Studio

C# Tools 2.8.0-beta4-62825-01. Commit Hash: 941725e0ef87022f098789c0cdba2f5b42816e20 C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Common Azure Tools 1.10 Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.

Fabric.DiagnosticEvents 1.0 Fabric Diagnostic Events

GitHub.VisualStudio 2.5.1.2234 A Visual Studio Extension that brings the GitHub Flow into Visual Studio.

JavaScript Language Service 2.0 JavaScript Language Service

JavaScript Project System 2.0 JavaScript Project System

JavaScript UWP Project System 2.0 JavaScript UWP Project System

Merq 1.1.17-rc (cba4571) Command Bus, Event Stream and Async Manager for Visual Studio extensions.

Microsoft Azure HDInsight Azure Node 2.3.3000.4 HDInsight Node under Azure Node

Microsoft Azure Hive Query Language Service 2.3.3000.4 Language service for Hive query

Microsoft Azure Service Fabric Tools for Visual Studio 2.1 Microsoft Azure Service Fabric Tools for Visual Studio

Microsoft Azure Stream Analytics Language Service 2.3.3000.4 Language service for Azure Stream Analytics

Microsoft Azure Stream Analytics Node 1.0 Azure Stream Analytics Node under Azure Node

Microsoft Azure Tools 2.9 Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.10420.2

Microsoft Continuous Delivery Tools for Visual Studio 0.3 Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.

Microsoft JVM Debugger 1.0 Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines

Microsoft MI-Based Debugger 1.0 Provides support for connecting Visual Studio to MI compatible debuggers

Microsoft Visual Studio Tools for Containers 1.1 Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.

Microsoft Visual Studio VC Package 1.0 Microsoft Visual Studio VC Package

Mono Debugging for Visual Studio 4.10.5-pre (ab58725) Support for debugging Mono processes with Visual Studio.

NuGet Package Manager 4.6.0 NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.

ProjectServicesPackage Extension 1.0 ProjectServicesPackage Visual Studio Extension Detailed Info

ResourcePackage Extension 1.0 ResourcePackage Visual Studio Extension Detailed Info

SQL Server Data Tools 15.1.61804.210 Microsoft SQL Server Data Tools

ToolWindowHostedEditor 1.0 Hosting json editor into a tool window

TypeScript Tools 15.7.20419.2003 TypeScript Tools for Microsoft Visual Studio

Visual Basic Tools 2.8.0-beta4-62825-01. Commit Hash: 941725e0ef87022f098789c0cdba2f5b42816e20 Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.

Visual F# Tools 10.1 for F# 4.1 15.7.0.0. Commit Hash: 16ecf5a30ad868d183c58e4a71a71c23d4ed3ba9. Microsoft Visual F# Tools 10.1 for F# 4.1

Visual Studio Code Debug Adapter Host Package 1.0 Interop layer for hosting Visual Studio Code debug adapters in Visual Studio

Visual Studio Tools for Apache Cordova 15.123.7408.1 Visual Studio Tools for Apache Cordova

Visual Studio Tools for Universal Windows Apps 15.0.27625.00 The Visual Studio Tools for Universal Windows apps allow you to build a single universal app experience that can reach every device running Windows 10: phone, tablet, PC, and more. It includes the Microsoft Windows 10 Software Development Kit.

VisualStudio.Mac 1.0 Mac Extension for Visual Studio

Windows Machine Learning Generator Extension 1.0 Windows Machine Learning Visual Studio Extension Detailed Info

Xamarin 4.10.0.440 (943b34d9d) Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.

Xamarin Designer 4.12.257 (94863902d) Visual Studio extension to enable Xamarin Designer tools in Visual Studio.

Xamarin.Android SDK 8.3.0.18 (HEAD/1f8462ef1) Xamarin.Android Reference Assemblies and MSBuild support.

Xamarin.iOS and Xamarin.Mac SDK 11.10.1.174 (f493322) Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.

nickrandolph commented 6 years ago

@onovotny have you seen anything like this - looping you in as the father of multi-targeting as I'm guessing it might be related. Seems that for some reason the Android SDK doesn't like our multi-targeted library.

nickrandolph commented 6 years ago

FYI we managed to get v3 working with mvvmcross (see https://github.com/MvvmCross/MvvmCross/pull/2864) thanks to @martijn00. Still not sure exactly what the issue was, probably nuget related we think.

nickrandolph commented 6 years ago

Ok, cancel that. Apparently the 6.1.0 branch of MvvmCross (https://github.com/MvvmCross/MvvmCross/tree/release/6.1.0) now builds for some people. For me it has the same issue described above. I've upgraded to 15.8 preview 1.1, but still seeing same issue

jassmith commented 6 years ago

MvvmCross has fixed this upstream.

nickrandolph commented 6 years ago

@jassmith not sure what you're talking about - is there a PR I missed that fixes this issue? I've been talking with @martijn00 and we're still blocked (as of 3hrs ago)

jassmith commented 6 years ago

I must be misreading this PR?

builttoroamadmin commented 6 years ago

Check the issue though, and my subsequent comment. Please reopen this as it’s a major blocker for us atm

jassmith commented 6 years ago

Can you link me to your comments?

jassmith commented 6 years ago

image

So thats not supposed to work?

jassmith commented 6 years ago

Thats using XF 3.0

jassmith commented 6 years ago

I reprod the issue. Xamarin.Mac doesn't want to accept the multi-targeting with .NET standard (I had mac disabled on my machine for other reasons). Dont multitarget its dll and you're good to go. There is probably a way to coax it into doing multitargeting but it seems not worth the effort.

jassmith commented 6 years ago
<ItemGroup Condition=" $(TargetFramework.StartsWith('Xamarin.Mac')) ">
   <Reference Include="netstandard" />
</ItemGroup>

You are missing that in your .csproj file. Adding that will make it build. I didn't have Mac enabled the first time hence why it didn't work.

After you add that please close VS, nuke bin/obj and relaunch. Just to be sure old state isn't being kept around.

nickrandolph commented 6 years ago

Ok for me I was seeing the same issue with the Android build. I'll see if adding that reference for Android fixes it there too.

nickrandolph commented 6 years ago

Hey thanks for investigating. I'm sure that I tried something similar to this but perhaps I didn't flush everything properly last time. Anyhow, just did a successful build of Android and Mac and seems to be working (touch wood), so a big thank you!