1
votes

So I've been trying to make a project that will use netstandard class libraries common code however I have been unsuccessful as I keep running into errors. I have been following the post here https://oren.codes/2016/07/09/using-xamarin-forms-with-net-standard/ and https://xamarinhelp.com/dot-net-standard-pcl-xamarin-forms/ on how to do it. His sample I can download and run fine but when I try replicate it with his instructions I run into the error

Your project is not referencing the ".NETPortable,Version=v4.5,Profile=Profile111" framework. Add a reference to ".NETPortable,Version=v4.5,Profile=Profile111" in the "frameworks" section of your project.json, and then re-run NuGet restore. FixMyCity.Mobile C:\Program Files (x86)\MSBuild\Microsoft\NuGet\Microsoft.NuGet.targets 140

Which I know it sounds obvious; just add .NETPortable,Version=v4.5,Profile=Profile111 in the frameworks section of project.json but then I get this error (80% certain it's caused by adding it in since it's not there otherwise)

Packages containing MSBuild targets and props files cannot be fully installed in projects targeting multiple frameworks. The MSBuild targets and props files have been ignored. ...project.nuget.targets

Also when I look at the sample project, he does not target .NETPortable,Version=v4.5,Profile=Profile111 and it works fine

This is the closest I've gotten with it so far if you would like to take a look: https://github.com/Toxicable/XamarinFormsNetstandardIssue
It's just the template project (Xamrin forms protalble) with the steps below applied

  1. Run `PM> Uninstall-Package xamarin.forms -Force -RemoveDependencies on each project; IOS and Andriod first PCL last.
  2. Restart VS as prompted by console
  3. Add in project.json to each project as below
  4. Try build but well it wont

PCL project.json

{
  "supports": {},
  "dependencies": {
    "Xamarin.Forms": "2.3.0.107",
    "NETStandard.Library": "1.6.0"
  },
  "frameworks": {
    "netstandard1.1": {
      "imports": "portable-net45+win8+wpa81+wp8"
    },
    ".NETPortable,Version=v4.5,Profile=Profile111": {}
  }
}

project.Driod project.json

{
  "dependencies": {
  },
  "frameworks": {
    "MonoAndroid,Version=v6.0": {
    }
  },
  "runtimes": {
    "win": {}
  }
}

project.iOS project.json

{
  "dependencies": {
  },
  "frameworks": {
    "Xamarin.iOS,Version=v1.0": {
    }
  },
  "runtimes": {
    "win": {}
  }
}
1
Have you seen the notes on Cycle 7 Service Release 1? releases.xamarin.com/… These builds introduce compatibility with the new .NET Standard 1.6. This in particular allows developers to consume NuGet packages that have been built against the .NET Standard 1.6.Jon Douglas
@JonDouglasI have seen that, how ever I am unsure what that has to do with my issue, im targeting a low Net Standard since it is most compatible but will change to the highest I can to target iOS and Andriod which is 1.6 I think once the project actually buildsToxicable

1 Answers

1
votes

I downloaded your project and noticed that the Xamarin Forms Portable Library was looking a little odd, you would normally see the Xamarin Forms and .NET Standard Library in your references with the blue icon.

I am not sure how it happened but here is how you fix it.

  1. Remove ".NETPortable,Version=v4.5,Profile=Profile111": {} from your project.json.

  2. Unload your project

  3. Edit the project file

enter image description here

  1. Remove this line <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>

  2. Change v4.5 to v5.0 <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>

  3. Save the file and reload the project and it now builds without the need for Profile111 and will also show the references

enter image description here