2
votes

I'm currently working on a Xamarin.Forms project named ABCD, using macOS Sierra v10.12.6 and Visual Studio (VS) for Mac v7.3.2 (the steps leading up to this problem are detailed here).

Having updated my NETStandard.Library package from version 1.6.0 to 2.0.1*, I notice that the project.json file still says:

"frameworks": {
"netstandard1.5": {}
}

*VS update this package to 2.0.1, despite Terminal showing that dotnet --version is 2.1.3.

I went ahead and replaced netstandard1.5 with netstandard2.0 and rebuilt the project. But was then immediately met with this error:

Error: Your project is not referencing the ".NETPlatform,Version=v5.0" framework. Add a reference to ".NETPlatform,Version=v5.0" in the "frameworks" section of your project.json, and then re-run NuGet restore. (ABCD)

I've tried to fix this in the following ways:

1 – Updating project.json:

"frameworks": {
    "netstandard2.0": {},
    ".NETPlatform,Version=v5.0": {}
}

2 (source) – Updating project.json:

"frameworks": {
    "netstandard2.0": {},
    ".NETPlatform,Version=v5.0": {
        "imports": ["netstandard2.0"]
}

3 (source) – Updating project.json:

"frameworks": {
    "netstandard2.0": {},
    ".NETPlatform,Version=v5.0": {
        "imports": [".NETCore,Version=v5.0"]
}

4 (source) – Updating project.json:

"frameworks": {
    "netstandard2.0": {
        "imports": [".NETCore,Version=v5.0"]
}

5 (source) – Updating project.json:

"frameworks": {
    ".NETPlatform,Version=v5.0": {
        "imports": ["netstandard2.0"]
}

6 (source, source) – Updating ABCD.csproj:

<PropertyGroup> 
    <NuGetTargetMoniker> .NETStandard,Version=v2.0 </NuGetTargetMoniker> 
</PropertyGroup>

I thought I might find something helpful here and here but wasn't successful.

The same error from above still remains after having tried the above fixes. How do I fix this?

EDIT:

7 (source) – Updating project.json:

"frameworks": {
    "netstandard2.0": {},
    "netplatform50": {}
}

Still seeing the same error.

1
This post suggests that the correct moniker is "netplatform50". Sounds right. Yuck what a mess, be sure to update your tooling.Hans Passant
Thank you for the suggestion, but that didn't solve the problem.user2323030

1 Answers

0
votes

This post suggests not using project.json but instead to do a dotnet migrate in your project root folder to convert it so that it uses .csproj instead