locked
Targeting .NET Standard RRS feed

  • Question

  • User37558 posted

    I read this article a while ago: https://blog.xamarin.com/net-standard-library-support-for-xamarin/

    So, I converted all of our libraries from portable libraries to .NET Standard (1.4). I did this because the article says "This PCL now needs to be upgraded to target the .NET Standard Library, which can be found in the projects properties.".

    However, I can't figure out how to build a Xamarin Forms project that targets .NET Standard. I cloned the Xamarin Forms samples, and opened up the MasterDetailPage project. I went in to the project properties and switched from portable to .NET Standard as per the instructions. Immediately, I get an error telling me that I need to opt in to NuGet 3.0 support. I'm fine with this, but how do I do it?

    I found that if I remove the Xamarin Forms NuGet package, I am able to switch over to .NET Standard. However, once I have done this, I can't add the Xamarin Forms NuGet package back. It just keeps failing. Contrary to what the article says, I cannot add references to .NET Standard libraries. When I try to add a reference to existing .NET Standard libraries in my Solution, Visual Studio just gives me an error saying that the library is not compatible. Which version of .NET Standard should I be targeting for Xamarin Forms?

    How do I get a .NET Standard library compiling with Xamarin Forms support?

    Tuesday, January 10, 2017 12:06 AM

Answers

  • User37558 posted

    Answer Found!

    The main thing I was doing wrong was trying to use the Visual Studio front end to switch over to .NET Standard. You can't do it that way. You have to manually create and edit the project.json. This article helped a lot: https://xamarinhelp.com/dot-net-standard-pcl-xamarin-forms/

    If you still can't get it working, there is a Git Repo which has a working version here: https://github.com/adamped/XamarinForms.NetStandard.git

    In the end, I was able to target .NET Standard 1.4. I was able to reference my existing .NET Standard 1.4 libraries, and this runs on at least Windows UWP. I'm now going to test the other platforms.

    @mattward , it was just the standard that comes with the MasterDetailPage sample: none. It was using the old packages.config version of NuGet. Part of the solution, as mentioned above is to switch to the project.json. Apparently, Microsoft is going to ditch project.json soon though so I look forward to more problems when that happens.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, January 10, 2017 10:28 PM
  • User107479 posted

    Your project.json file should look something like this.

    {
      "supports": {},
      "dependencies": {
        ...
      },
      "frameworks": {
        "netstandard1.4": {
          "imports": "portable-net45+win8+wpa81+wp8"
        }
      }
    }
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, January 10, 2017 10:31 PM
  • User37558 posted

    It depends on how your solution is structured.

    I have a sample solution with a base .NET Standard/PCL library (CF.RESTClient.NET.Standard). On top of that, I have another sample app that is Xamarin Forms - .NET Standard/PCL (CF.RESTClient.NET.Sample). This project references Newtonsoft's JSON parser. Then, all of the platform specific projects (iOS, UWP, Android) references that project. Each platform specific project also references Newtonsoft. I believe that this is a good structure.

    It means that I can keep clean .NET Standard logic (not Xamarin Forms) in the lowest library (CF.RESTClient.NET.Standard). This can be shared by a .NET/.NET Core app as well. But, all of the UI is in the shared .NET Standard Xamarin Forms library CF.RESTClient.NET.Sample so I don't need to write any platform specific UI.

    Clone the repo here: https://MelbourneDeveloper@bitbucket.org/MelbourneDeveloper/restclient-.net.git

    Website: https://bitbucket.org/MelbourneDeveloper/restclient-.net

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, July 5, 2017 11:23 PM

All replies

  • User76049 posted

    @ChristianFindlay

    Check this blog post, might help

    https://oren.codes/2016/07/09/using-xamarin-forms-with-net-standard/

    This is required to tell NuGet that specified TFM is compabtible here because the Xamarin.Forms package has not yet been updated to use netstandard directly.

    Tuesday, January 10, 2017 12:18 AM
  • User37558 posted

    @NMackay , sorry, but this doesn't help. I was able to follow some of the steps in this post: https://oren.codes/2016/02/08/project-json-all-the-things/ to convert the Xamarin Forms project to NuGet 3.0. Once I did that, I was able to convert the Xamarin Forms project to .NET Standard 1.4 without any errors. But, The project doesn't compile at all. It appears that the project won't accept the Xamarin Forms libraries inside the NuGet package because everything related to Xamarin Forms causes a compilation error.

    One of the compilation errors is this: Package Xamarin.Forms 2.3.3.180 is not compatible with netstandard1.4 (.NETStandard,Version=v1.4). I get the same error in .NET Standard 1.6 as well.

    Tuesday, January 10, 2017 1:07 AM
  • User37558 posted

    Severity Code Description Project File Line Suppression State Error Package Xamarin.Forms 2.3.3.180 is not compatible with netstandard1.4 (.NETStandard,Version=v1.4). Package Xamarin.Forms 2.3.3.180 supports: - monoandroid10 (MonoAndroid,Version=v1.0) - portable-monoandroid10+net45+win+win81+wp8+wpa81+xamarinios10+xamarinmac20 (.NETPortable,Version=v0.0,Profile=win+net45+wp80+win81+wpa81+MonoAndroid10+Xamarin.iOS10+xamarinmac20) - uap10.0 (UAP,Version=v10.0) - win81 (Windows,Version=v8.1) - wp8 (WindowsPhone,Version=v8.0) - wpa81 (WindowsPhoneApp,Version=v8.1) - xamarinios10 (Xamarin.iOS,Version=v1.0) 0

    Tuesday, January 10, 2017 1:13 AM
  • User37558 posted

    So, can I basically take it that you cannot create a Xamarin Forms library for .NET Standard?

    This is a MASSIVE problem. Why was it advertised that Xamarin would support .NET Standard 6 months ago, and there is still no .NET Standard support for Xamarin Forms?

    Tuesday, January 10, 2017 1:15 AM
  • User18049 posted

    What does your project.json file look like?

    Tuesday, January 10, 2017 9:54 PM
  • User37558 posted

    Answer Found!

    The main thing I was doing wrong was trying to use the Visual Studio front end to switch over to .NET Standard. You can't do it that way. You have to manually create and edit the project.json. This article helped a lot: https://xamarinhelp.com/dot-net-standard-pcl-xamarin-forms/

    If you still can't get it working, there is a Git Repo which has a working version here: https://github.com/adamped/XamarinForms.NetStandard.git

    In the end, I was able to target .NET Standard 1.4. I was able to reference my existing .NET Standard 1.4 libraries, and this runs on at least Windows UWP. I'm now going to test the other platforms.

    @mattward , it was just the standard that comes with the MasterDetailPage sample: none. It was using the old packages.config version of NuGet. Part of the solution, as mentioned above is to switch to the project.json. Apparently, Microsoft is going to ditch project.json soon though so I look forward to more problems when that happens.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, January 10, 2017 10:28 PM
  • User107479 posted

    Your project.json file should look something like this.

    {
      "supports": {},
      "dependencies": {
        ...
      },
      "frameworks": {
        "netstandard1.4": {
          "imports": "portable-net45+win8+wpa81+wp8"
        }
      }
    }
    
    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Tuesday, January 10, 2017 10:31 PM
  • User37558 posted

    That's correct. It ended up like this:

    {
      "supports": {},
      "dependencies": {
        "DeltaDCC": "1.0.0",
        "NETStandard.Library": "1.6.0",
        "Xamarin.Forms": "2.3.1.114"
      },
      "frameworks": {
        "netstandard1.4": {
          "imports": "portable-win+net45+wp8+win81+wpa8"
        }
      }
    }
    
    Tuesday, January 10, 2017 10:33 PM
  • User18049 posted

    @ChristianFindlay - In .NET Core projects, which support creating .NETStandard libraries and are what is the planned replacement for using project.json files, the imports in the project.json file maps to a PackageTargetFallback element in the .csproj file.

     <PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
    
    Tuesday, January 10, 2017 10:59 PM
  • User37558 posted

    @mattward , I don't follow. What are you trying to tell me?

    Wednesday, January 11, 2017 12:41 AM
  • User18049 posted

    @ChristianFindlay - You said 'Apparently, Microsoft is going to ditch project.json soon though so I look forward to more problems when that happens.' so I was just talking about what you may need to do in the future if you switch away from project.json. Although I don't think there are any plans to cause project.json to stop working in the future.

    Wednesday, January 11, 2017 9:10 AM
  • User176749 posted

    @MelbourneDeveloper what is the main advantage of using .net libraries? I always think some of nuget packages might not support .net standard. so in this case is it possible to mix? I mean are we still able to use that package doest support .net standard?

    Sunday, May 14, 2017 11:08 AM
  • User37558 posted

    I like .NET standard because it is supported by all platforms except for Silverlight. In Xamarin, you still have to target PCL in your .NET Standard project, but basically, you can use the same DLL over just about everything: .NET, Android, iOS, UWP, .NET Core etc.

    Sunday, May 14, 2017 11:17 PM
  • User176749 posted

    @MelbourneDeveloper said: I like .NET standard because it is supported by all platforms except for Silverlight. In Xamarin, you still have to target PCL in your .NET Standard project, but basically, you can use the same DLL over just about everything: .NET, Android, iOS, UWP, .NET Core etc.

    for example. i am using Freshmvvm and it doesnt support .net standard, does it mean if I convert to use .net standard, I will not able to use Freshmvvm anymore. Vice versa, my PCL project is .net standard, Sensors package uses .net standard, am I not able to use it until I convert my PCL into .net standard?

    Thursday, May 18, 2017 10:28 PM
  • User37558 posted

    @batmaci ,

    I don't really understand your questions. Here's how you can look at it:

    .NET Standard is simply a set of APIs. They are versioned. You can target this assembly format and reference it from most platforms except for Silverlight. However, some libraries will need the assembly to also target PCL. A .NET Standard library can target PCL as well. See the answers for this thread to see how to do that,

    Thursday, May 18, 2017 11:18 PM
  • User172704 posted

    Does anyone know if there has been any movement on this? I have tried uninstalling all nuget packages, checked I am on nuget V3, switched all my PCLs to target .NET Standard, and Xamarin.Forms claims not to be compatible and fails to install.

    I have tried .NET Standard 1.5, 1.4, 1.3 and 1.1, all with the same result shown below:

    Restoring packages for D:\Data\Work\Dev\Projects\Live\Serenocalm\Serenocalm.Forms\project.json...
    Xamarin.Forms 2.3.4.247 is not compatible with .NETStandard,Version=v1.1.
    Some packages are not compatible with .NETStandard,Version=v1.1.
    Package restore failed for 'Serenocalm.Forms'.
    Package restore failed. Rolling back package changes for 'Serenocalm.Forms'.
    

    Does anyone know how to fix this?

    Incidentally, I am trying to fix this because SkiaSharp will not install in a project that targets .NET 4.5 (see https://forums.xamarin.com/discussion/96229/how-do-i-get-skiasharp-to-build-now-i-have-updated-xamarin).

    Any help anyone? Completely stuck here. I've had a project that's been building for months, then a Xamarin update broke it yesterday and I can't get a working build at all. Spent about six hours on this so far. Life's just too short for this s**t.

    Wednesday, May 24, 2017 11:36 AM
  • User3516 posted

    @EasyGoingPat

    It should work if you added the following line as described in the accepted answer:

    "imports": "portable-net45+win8+wpa81+wp8"

    Can you show us your project.json?

    Wednesday, May 24, 2017 12:03 PM
  • User172704 posted

    @DirkWilhelm Thank you for the reply.

    I must have had something wrong. I have now got further than I got before with the .json file posted below. Unfortunately, I now get 20-30 cases of the following error:

    3>D:\Data\Work\Dev\Projects\Live\MyProject\MyProject.Forms\obj\Debug\MyProject.Forms.Views.SettingsView.xaml.g.cs(18,42,18,64): error CS1069: The type name 'GeneratedCodeAttributeAttribute' could not be found in the namespace 'System.CodeDom.Compiler'. This type has been forwarded to assembly 'System.Diagnostics.Tools, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.

    .json file:

    {
      "supports": {},
      "dependencies": {
        "Microsoft.NETCore.Portable.Compatibility": "1.0.1",
        "NETStandard.Library": "1.6.0",
        "PCLStorage": "1.0.2",
        "SkiaSharp": "1.58.0",
        "SkiaSharp.Views.Forms": "1.58.0",
        "Xamarin.Forms": "2.3.4.247",
        "Xamarin.Microsoft.Band": "1.3.10.1"
      },
      "frameworks": {
        "netstandard1.4": {
          "imports": "portable-win+net45+wp8+win81+wp8"
        }
      }
    }
    

    I'll attempt to do what the error suggests, to see how that goes.

    Wednesday, May 24, 2017 4:15 PM
  • User326592 posted

    Using VS 2015 Update 3, Xamarin.Forms 2.3.4.247 and .NET Standard 1.4 (followed the project.json conversion tutorial), I also get "CodeDom does not exist in this namespace".

    I simply created a Xamarin cross-platform app with the Master Detail template, and attempted conversion to .NET Standard 1.4.

    Friday, May 26, 2017 5:53 PM
  • User228961 posted

    @EasyGoingPat I got the same issue. Could you solve it? Adding System.Diagnostics.Tools to the project.json doesn't resolve the issue.

    Monday, May 29, 2017 8:58 AM
  • User172704 posted

    @XanderLo @TimS No, I haven't managed to fix this. I've had to switch to another non-Xamarin project because of a deadline, so I'm kind-of hoping that all this malarkey will be fixed 'properly' when I get back to it. If you find a workaround, I would love to hear it.

    Monday, May 29, 2017 10:00 AM
  • User37558 posted

    Welcome to Xamarin DLL hell.> @EasyGoingPat said:

    @XanderLo @TimS No, I haven't managed to fix this. I've had to switch to another non-Xamarin project because of a deadline, so I'm kind-of hoping that all this malarkey will be fixed 'properly' when I get back to it. If you find a workaround, I would love to hear it.

    Grab the working project here: https://github.com/adamped/XamarinForms.NetStandard.git

    Wednesday, May 31, 2017 3:34 AM
  • User326592 posted

    Hi All,

    I actually managed to fix those compilation issues by installing the latest .NET Core SDK and .NET Core VS2015 Tools Preview 2.

    Thanks!

    Thursday, June 1, 2017 12:54 AM
  • User328763 posted

    I had trouble converting PCL to .NET standard so I created a brand new project to test. I have got it down to one error now when compiling: CS0246 The type or namespace name 'NeutralResourcesLanguageAttribute' could not be found (are you missing a using directive or an assembly reference?) (in AssemblyInfo.cs) The only way I can get it to compile it to manually comment out the line below in AssemblyInfo.cs, is this something I need to be concerned about? [assembly: NeutralResourcesLanguage("en")]

    This is my config:

    • Installed packages (only these are installed):

      • NETStandard.Library v1.6.1 (also tried v1.6.0)
      • Xamarin.Forms v2.3.4.247
      • Microsoft.NETCore.Portable.Compatibilty v1.0.1 (Have tried with and with this installed)
    • Target: I have tried .NETStandard 1.1, 1.3, 1.5

    • Project.json: { "supports": {}, "dependencies": { "Xamarin.Forms": "2.3.4.247", "NETStandard.Library": "1.6.0", "Microsoft.NETCore.Portable.Compatibility": "1.0.1" }, "frameworks": { "netstandard1.3": { "imports": "portable-net45+win8+wpa81+wp8" } } }

    • Visual Studio 2015 SP3

    I have no other references and the project is empty. In visual studio have cleaned, reloaded, and run VS "as admin"

    UPDATE: Actually, in addition to the 'NeutralResourcesLanguage' issue/workaround above, as soon as I add a content page to the project I get a compilation error for every control on the page (I see other posts above have mentioned this problem too):

    CS1069 The type name 'GeneratedCodeAttributeAttribute' could not be found in the namespace 'System.CodeDom.Compiler'. This type has been forwarded to assembly 'System.Diagnostics.Tools, Version=0.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' Consider adding a reference to that assembly.

    and then, for that page:

    Build action 'EmbeddedResource' is not supported by one or more of the project's targets.

    Has anyone actually got Xamarin working with .NETStandard?

    Wednesday, June 14, 2017 2:21 PM
  • Thursday, June 15, 2017 10:51 PM
  • User328763 posted

    Ok, so it looks as though this is for VS2017 only then? I don't have it installed yet but try again when I have it.

    Thursday, June 29, 2017 7:10 AM
  • User176749 posted

    Can somebody please explain me this bullshit? Why most the of the libraries require to use profile259 instead of profile111 if windows phone8.0 is deprecated. Only difference between them is WP8.0 that profile111 doesn't have it. Please dont tell me that change your project to .net standard instead of xamarin profile. this is not easy for existing project if some nugets like freshmvvm doesnt support yet .net standard.

    Friday, June 30, 2017 12:41 AM
  • User37558 posted

    Hahaha. This stuff puzzles me too. But, it's not all that complicated. I just create a .NET Standard library (1.4) that also targets PCL. That way it works on .NET, iOS, Android, UWP, and .NET Core.

    Here are a few repos where I have sample apps that leverage a .NET Standard library across several .NET/Xamarin platforms:

    https://github.com/MelbourneDeveloper/SQLite.Net.Standard (Tested) https://bitbucket.org/MelbourneDeveloper/restclient-.net (Tested) https://github.com/MelbourneDeveloper/Adapt.Presentation (Maybe tested?)

    You can use theses samples to create a solution with multiple platforms that all leverage the same Xamarin Forms .NET Standard library.

    Friday, June 30, 2017 3:09 AM
  • User240159 posted

    @batmaci said: Can somebody please explain me this bullshit? Why most the of the libraries require to use profile259 instead of profile111 if windows phone8.0 is deprecated. Only difference between them is WP8.0 that profile111 doesn't have it. Please dont tell me that change your project to .net standard instead of xamarin profile. this is not easy for existing project if some nugets like freshmvvm doesnt support yet .net standard.

    I've spend whole weekend, for trying to "port" my Xamarin Forms app to: - Profile111 (because latest releases of ACR.UserDialogs and some other 3rd party plugins didn't support Profile259), but some other 3rd party plugins didn't support Profile111 (can't remember exact which one, but most probably some sqlite) then to: -.NET Standard 1.7 (latest stable .NET Standard), but some other 3rd party plugins also didn't support .NET Standard...

    Exerything (reinstalling nugets, changing profile, workarounding whole project for .NET Standard) took soo long, and it's so f..ing annoying -.-

    Friday, June 30, 2017 6:20 AM
  • User176749 posted

    @MelbourneDeveloper I have already created .net standard 1.4 class library but my XF project has profile111 and when I compile it, it complains that it cant work with Profile111. It requires 259, I dont know what else do you mean?

    Friday, June 30, 2017 12:48 PM
  • User187527 posted

    For all the people that are having troubles moving to .NET standard, you have several options:

    1. You don't have to do it. The PCL versions of plugins work just fine
    2. Plugin devs are trying to hit .NET standard 1.0 which installs fine into PCL profile 259 (where possible). .NET standard 1.1 installs fine in PCL profile 111. https://docs.microsoft.com/en-us/dotnet/standard/net-standard
    3. If you don't like the directional shift, you can always clone the plugin projects to work with in the meantime.

    For people that are having trouble with Xamarin Forms: .NET standard is only supported 2.3.5 which is in preview on nuget. 2.3.4 is only PCL.

    The fact is, the industry is moving this way. OSS is going to move with it because we generally like to be up to date and we don't have time to support the past. There is no doubt that tooling and plan around .NET standard has been a mess to say the least, but I think Microsoft is almost there.

    Friday, June 30, 2017 1:30 PM
  • User176749 posted

    @MelbourneDeveloper I just understood your suggestion. this perfectly working. for those who needs details. - open class library as PCL (not .net standard) - Uninstall Xamarin.forms nuget - Right Click on project and change the target to .net standard 1.4

    Now you can add reference on main PCL project. this works fine for me.

    Friday, June 30, 2017 5:32 PM
  • User37558 posted

    Yep. That's right.

    Sunday, July 2, 2017 11:26 PM
  • User172554 posted

    I have successfully converted a PCL project to .NetStandard. Now I need to add a new NuGet package (for instance Newtonsoft.Json). Do I have to add the NuGet package to the .NetStandard DLL project, and also to each of the *.Android, *.UWP and *.iOS projects ?

    Wednesday, July 5, 2017 9:45 AM
  • User37558 posted

    It depends on how your solution is structured.

    I have a sample solution with a base .NET Standard/PCL library (CF.RESTClient.NET.Standard). On top of that, I have another sample app that is Xamarin Forms - .NET Standard/PCL (CF.RESTClient.NET.Sample). This project references Newtonsoft's JSON parser. Then, all of the platform specific projects (iOS, UWP, Android) references that project. Each platform specific project also references Newtonsoft. I believe that this is a good structure.

    It means that I can keep clean .NET Standard logic (not Xamarin Forms) in the lowest library (CF.RESTClient.NET.Standard). This can be shared by a .NET/.NET Core app as well. But, all of the UI is in the shared .NET Standard Xamarin Forms library CF.RESTClient.NET.Sample so I don't need to write any platform specific UI.

    Clone the repo here: https://MelbourneDeveloper@bitbucket.org/MelbourneDeveloper/restclient-.net.git

    Website: https://bitbucket.org/MelbourneDeveloper/restclient-.net

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Wednesday, July 5, 2017 11:23 PM
  • User172554 posted

    Ok, thanks. That means the recommendation is that Xamarin.Forms should be used only in the shared part. The Xamarin.Forms NuGet package is then installed only in the *.Android, *.UWP and *.iOS projects, and the .NetStandard dll should not use Xamarin.Forms. I have an application which has in the .NetStandard dll some bootstraper code and some navigation service class that need Xamarin.Forms. Should I move them to the shared project, or create a second .Net Standard dll, which would be dependent on Xamarin.Forms ?

    Friday, July 7, 2017 3:02 PM
  • User37558 posted

    I hope I'm not miscommunicating things here. There are many ways to structure your app. It's just that my basic guidelines are like this:

    • Any non UI code (not Xamarin specific) should go in a single .NET Standard /PCL library that can be shared across all platforms. This library doesn't need to reference the Xamarin Forms dependencies if you want the library to be usable from platforms outside Xamarin (E.g. .NET, .NET Core). This can include interfaces etc. for factory classes that mint platform specific objects (dependency injection).
    • Any UI code (Xamarin Forms) that is not platform specific should go in a single .NET Standard / PCL. This can include interfaces etc. for UI factory classes that mint platform specific objects (dependency injection). It might have basic Xamarin Forms controls or app specific screens. You may, or may not want to combine this with the above library.
    • Lastly, you will need your platform specific libraries. This is for the bits and pieces that are not generic across all platforms. They may be custom renderers for your controls, or they may just implement functionality that is specific to the platform. Often I try to implement the factory interfaces from the above libraries so that the factory classes can be used to mint objects seamlessly without needing logic like

      if (Android) { camera = new AndroidCamera(); }

    Instead you'd have logic like

    camera = CameraFactory.CreateCamera();
    
    Saturday, July 8, 2017 1:09 AM
  • User163022 posted

    I'm just going to leave this here: Its allot newer and you don't have to do most of the things you guys mention here: https://blog.xamarin.com/building-xamarin-forms-apps-net-standard/

    Wednesday, July 12, 2017 2:21 PM
  • User342082 posted

    after upgrade to VS 2017 15.3 , this is not working . the import since like stop working as the error message about the Xamarin.forms not targeting to .net Standard come back.

    the project working well in 15.2 . any Idea?

    Friday, August 18, 2017 9:30 PM
  • User24645 posted

    Note: I work for Microsoft, but this is not representative of the company as an offical answer. I just do Xamarin in my free time.

    This might help..

    Create a new ".NET Standard Library"

    Then edit the .csProj file to the following.

        <Project Sdk="Microsoft.NET.Sdk">
    
          <PropertyGroup>
            <TargetFramework>netstandard1.4</TargetFramework>
            <PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8</PackageTargetFallback>
          </PropertyGroup>
    
    
        Other stuff here
        </Project>
    

    What this basically does is tell VS that you are accepting/compatible of these other frameworks... This allows you to download nuget packages and it should work the same as the no longer working project.json files above.

    I put a link to the test project if your interested to see full copy.

    (Download at) https://www.cameronmoten.com/2017/08/19/fixing-xamarin-with-net-standard-in-visual-studio-2017-v-15-3/

    Saturday, August 19, 2017 6:39 AM
  • User24645 posted

    Note: I work for Microsoft who is the Parent Company but this is not an offical answer. I just do Xamarin in my free time & reflects only personal debugging.

    Edit the .csProj file for the .Net Standard Library...

    Add this line below for the "Package Target Fallback". You might have to create a new .NET Standard Library and then copy them over if not.

    < PropertyGroup> < TargetFramework >netstandard1.4< /TargetFramework> < PackageTargetFallback >$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8< /PackageTargetFallback > < /PropertyGroup>

    Grab my zip / Project file below here along with some more instructions if you want to see it for yourself! [https://www.cameronmoten.com/2017/08/19/fixing-xamarin-with-net-standard-in-visual-studio-2017-v-15-3/ ](https://www.cameronmoten.com/2017/08/19/fixing-xamarin-with-net-standard-in-visual-studio-2017-v-15-3/ "https://www.cameronmoten.com/2017/08/19/fixing-xamarin-with-net-standard-in-visual-studio-2017-v-15-3/ ")

    Seems that my other comment got marked for Moderation since it had code, but here is my second try where i added spaces in the brackets.. :smile:

    Saturday, August 19, 2017 6:42 AM
  • User24645 posted

    Keeping getting my comment marked for Moderation.. But here's an answer.

    Note: I work for Microsoft but this isn't a Microsoft/Xamarin answer I just do Xamarin for fun.

    Change the .csproj file to the following for netstandard1.4 as the example.

    You must use this syntax instead of the project.json to get it to work

    <Project Sdk=”Microsoft.NET.Sdk”>
    
    <PropertyGroup>
    <TargetFramework>netstandard1.4</TargetFramework>
    <PackageTargetFallback>$(PackageTargetFallback);portable-win+net45+wp8+win81+wpa8</PackageTargetFallback>
    </PropertyGroup>
    
    
    
    Other stuff here
    </Project>
    

    Download my sample project here & some pictures https://www.cameronmoten.com/2017/08/19/fixing-xamarin-with-net-standard-in-visual-studio-2017-v-15-3/

    Saturday, August 19, 2017 7:12 PM
  • User326406 posted

    This fix didn't help me. It appears that a nuget manager update is forcefully removing some references in my nuget.targets and project.lock file.

    For example it removed the imports section from this block

    "netstandard1.6": { "imports": [ "portable-net45+win8+wp8+wpa81" ] }

    No mater what i do as soon as visual studio boots it deletes those lines. I think the root problem is the nuget 4.3.0 update.

    Thursday, August 24, 2017 4:03 PM
  • User283653 posted

    Noted, that for the note of @CameronMoten works for me, I had to create a new .Net standard project and copy paste the old classes.

    Thank you a lot

    Tuesday, August 29, 2017 9:48 AM
  • User37558 posted

    Something has gone wrong with this thread...

    I think posts have been deleted by moderators...

    Supposedly I created this thread? But, I can't see the OP.

    Wednesday, August 30, 2017 4:08 AM
  • User28603 posted

    I keep getting this error when I try to build a xamarin forms project that references a .net standard library (1.4)

    Error Project 'R:\Levitica\ACTracker\ACTracker.DTO\ACTracker.DTO.csproj' targets '.NETStandard,Version=v1.4'. It cannot be referenced by a project that targets '.NETPortable,Version=v4.5,Profile=Profile259'.

    Does anybody know what's happening and how to get it to work?

    Friday, September 29, 2017 8:22 PM
  • User240159 posted

    Does anyone successfullly targeted XF project to .NETStandard 2.0? Any even HelloWorld example at github? I have to stay with .NETStandard 1.4, because of maaany annoying issues during 1.4->2.0 conversion.

    Wednesday, October 11, 2017 2:02 PM
  • User176749 posted

    can we use 1.6 version Mono 8.0 or we should upgrade to standard2.0?

    Tuesday, January 30, 2018 6:23 PM