Targeting .NET Standard

2»

Answers

  • CameronMotenCameronMoten USMember
    edited August 19

    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/

    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:

  • CameronMotenCameronMoten USMember
    edited August 19

    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/

  • KiloKilo USMember

    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.

  • jlmjlm BEMember
    edited August 29

    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

  • MelbourneDeveloperMelbourneDeveloper AUMember ✭✭✭

    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.

  • stesvisstesvis USMember ✭✭✭

    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?

  • NamyslawSzymaniukNamyslawSzymaniuk USMember ✭✭✭

    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.

2»
Sign In or Register to comment.