Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not add nuget package to PCL project #60

Closed
slimjack opened this issue Aug 13, 2016 · 4 comments
Closed

Can not add nuget package to PCL project #60

slimjack opened this issue Aug 13, 2016 · 4 comments

Comments

@slimjack
Copy link

slimjack commented Aug 13, 2016

Hi,
I tried Zeroconf with usual Windows Forms project, and it works perfectly. Thank you for your work.

Now I'm trying to add Zeroconf to my PCL library (v4.5, Profile111). The first problem I run into was the same as described here (System.Runtime.InteropServices.RuntimeInformation installation failed)

I've applied project.json to my PCL libary (guide) and now instalation of Zeroconf is OK but buid is failed with

'C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets'
(1820,5): warning MSB3274: The primary reference "...\.nuget\packages\Zeroconf\2.8.0\lib\netstandard1.0\Zeroconf.dll" could not be resolved because it was built against the ".NETPortable,Version=v5.0" framework. This is a higher version than the currently targeted framework ".NETPortable,Version=v4.5,Profile=Profile111".

project.json:

{
  "dependencies": {
    "Zeroconf": "2.8.0"
  },
  "frameworks": {
    ".NETPortable,Version=v4.5,Profile=Profile111": {}
  },
  "supports": {}
}

Please, help me to add Zeroconf to my project.

@clairernovotny
Copy link
Collaborator

Unfortunately, it looks like you're hitting a different bug now :(
dotnet/roslyn#11067

I would recommend switching to a netstandard-based profile and this issue will go away. Is there any particular reason to target Profile 111 instead of netstandard1.1?

@slimjack
Copy link
Author

I've converted all projects in my Xamarin solution to netstandard1.1 (I used your guide) and now all works OK.

Thank you!

@cjrd
Copy link

cjrd commented Sep 6, 2016

@slimjack I'm running into similar issues: can you share your project.json you used to make this work?

Thanks!

@slimjack
Copy link
Author

slimjack commented Sep 7, 2016

Here is a project.json of the library that references Zeroconf:

{
  "supports": {},
    "dependencies": {
        "NETStandard.Library": "1.6.0",
        "Zeroconf": "2.8.0"
    },
  "frameworks": {
    "netstandard1.3": {}
  }
}

.csproj file:

...
  <PropertyGroup>
...
    <TargetFrameworkVersion>v5.0</TargetFrameworkVersion>
    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
...
  </PropertyGroup>
...

Xamarin common project project.json:

{
  "dependencies": {
    "NETStandard.Library": "1.6.0",
    "Xamarin.Forms": "2.3.2.118-pre1"
  },
  "frameworks": {
    "netstandard1.3": {
      "imports": "portable-net45+win8+wpa81+wp8"
    }
  },
  "supports": {}
}

Droid project.json:

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

Droid .csproj:

...
  <PropertyGroup>
...
    <ProjectTypeGuids>{EFBA0AD7-5A72-4C68-AF49-83D382785DCF};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <TargetFrameworkVersion>v6.0</TargetFrameworkVersion>
    <CopyNuGetImplementations>true</CopyNuGetImplementations>
...
  </PropertyGroup>
...

Look this example of Xamarin projects based on project.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants