nuget error installing protobuf-net on portable library - nuget

I'm trying to install protobuf-net (2.0.0.602) in a portable class library, I just can't seem to get this to work. I get this error:
PM> install-package protobuf-net
'protobuf-net 2.0.0.602' already installed.
install-package : Could not install package 'protobuf-net 2.0.0.602'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.0,Profile=Profile4', but
the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
Inspecting the package it appears to target portable-sl4+wp71+windows8, however when i create a vinalla project targeting these frameworks I can't get it to work (profile4 is listed above, but I've tried a few different ones to see what sticks). I've just updated nuget in studio. Running 'nuget' from the package manager console shows the nuget version as 2.1.31022.9038.
If I browse to the protobuf-net.dll within the package (under lib\portable-sl4+wp71+windows8) it will allow me to reference it and all is good.
I can just manually add it, but am I missing something obvious.
Any help appreciated.

This appears to be just a slight tweak needed to the nuget config; I had specified portable-sl4+wp71+windows8, when actually I needed to specify portable-sl4+net4+wp7+windows8, to include regular .NET.
This is fixed in 2.0.0.611, which has been pushed to NuGet.

Related

Using NuGet packages in VSIX extension

I am trying to build a VSIX extension that is using some NuGet packages.
When running the project I get an exception "Could not load file or assembly or its dependencies". I've included the package dlls themselves and they get copied over, but I suspect they're missing one of the numerous dependencies. But I don't know which ones.
I've found many old links here with similar issue and tried everything, but nothing seems to work.
Specifically I am trying to use MdXaml nuget package. It looks like it's relying on AvalonTextEdit, and that itself is relying on bunch of other stuff.

Nuget install failed: the package does not contain any assembly references or content files that are compatible with that framework

If I understand Scott Hanselman's post here correctly then I should be able to reference a .net standard library from a framework 4.7.2 solution.
I want to use Nuget to install such a reference.
I am using Azure DevOps Artifacts for the Nuget package. When I push my .net standard solution I can see that the package does create and that the Nuget install command is
Install-Package SBD.Standard -version 2.0.0-CI-etc
However when I try this at the PM console for my framework 4.7.2 project I get
Could not install package 'SBD.Standard 2.0.0-etc'. You are trying to install this package into a project that targets
'.NETFramework,Version=v4.7.2', but the package does not contain any assembly references or content files that are compatible with that
framework
moreover I do not see SBD.Standard as an avialable package in the relevant feed from within VS2019 -> Manage nuget packages for solution.
I think I need packages.config
I was able to create a new 4.7.2 project and add the nuget package that used .net standard 2.0 (but not 2.1)
When I tried to add the nuget package I got a dialog asking me to select the Nuget package manager format
so I chose Packages.config and that worked.
I am not sure I have it right. I solved my problem but am not sure whether this was it after all. SInce PackageReference is more recent it should work.
Some additional explanations for this issue.
There is an issue for NuGet restore when you using new SDK-based project type or PackageReference in the .net framework:
https://github.com/NuGet/Home/issues/5461
https://github.com/dotnet/sdk/issues/1755
When we use packages.config projects or non-SDK based project type, NuGet do not check compatibility during install/restore.
So, to resolve this issue, we need make sure the referenced project is an old style csproj or use packages.config.
That the reason why the packages.config works for you.
Hope this helps.

Private NuGet v.3 feed

I have a private NuGet 2.8.5 feed in my internal network, which I use as part of my environment.
I just found that it does not work with some new packages.
Particularly, this package reference the same assembly for two different evironments - DNX 4.5.1 and DNXCore 5.0
That causes following error:
'xunit.runner.dnx' already has a dependency defined for
'Microsoft.Framework.Runtime.Abstractions'.
It looks like NuGet v.2 problem.
NuGet Package Explorer UI tool has exactly the same problem...
So, how can I create a local NuGet v.3 feed, which could serve such packages?
This NuGet.Server package looks abandoned, and I'm not able to find its source code anymore...
A 2.8.6 version of Nuget.Server package got posted yesterday, probably after your post. Perhaps this will fix the problem?
https://www.nuget.org/packages/nuget.server

Internal NuGet install fails to install

I setup an internal NuGet server to host internal dll packages. The setup went smoothly. The spec and nupkg were created successfully. However, when I launch a test project and attempt to install it from Manage NuGet Packages it fails.
The internal package shows up under Manage NuGet Packages with an install button. I hit install but it does nothing. I check my references folder and saw nothing added.
If I check the Manage NuGet Packages at solution level, it has a green check mark indicate that it's installed but doesn't give me a Manage option to see which project it was installed to.
My issue is somewhat similar to this post below. The only difference is that I don't have sub folders for my library. I just have 1 dll and I'm putting the nupkg file directly under the Packages folder.
NuGet package fails to install
I'm not sure what I did wrong. Any suggestions?
Thanks to #MattWard for mentioned that the package got installed at the solution level. I went back to the official documentation here: https://docs.nuget.org/create/creating-and-publishing-a-package to review the differences with creating solution level package vs project level package and most important of all is the nuget naming convention when creating packages (the lib, content, etc. folder). I re-package my dll again with the naming convention and it works!

Cannot use home-made NuGet package

I'm investigating using NuGet internally to share an assembly used across multiple solutions. Despite the documentation making it look simple, I'm just getting a faceful of problems. I have two questions at this stage:
1) When I create the package, NuGet reports it as having 'no dependencies'. In fact, the assembly's project has quite a few dependencies on other (official) NuGet packages. I assumed that NuGet would spot this. Is there something I need to do so that NuGet knows my assembly itself has NuGet dependencies?
2) When I attempt to add the package to a project in another solution, it doesn't actually add the dll to the project (i.e. in the project's References). The package manager GUI lists the package in the installed list, but doesn't show a 'Manage' button, as it does for other packages. Instead, it just shows a 'Uninstall' button. So it's as if the overall solution is now aware of my package, but I can't add it as a reference to any projects, which is obviously of no use. This happens regardless of whether I install using the GUI or the command line. Does anyone know why this might be happening?
Thanks in advance.
For issue 1, if you are using nuget.exe pack and your project installed certain packages, these packages will be added as dependencies. If the packages are installed to another project that the main project is referencing, do nuget.exe pack -includereferencedprojects. For more information, please refer to http://docs.nuget.org/docs/reference/command-line-reference#Pack_Command_Examples.
For issue 2, you have probably installed a solution-level package, which does not have Content or Lib folder inside. If you install a project-level package, you should be able to see the manage button.
Hope this helps.