List nuget dependencies and their current versions - nuget

I have large, complicated solution with dependencies on many nuget packages. I want to find out the current versions of all my nuget dependencies.
At present i have a console application that looks through the source tree, finds all the packages.config files, extracts the relevant information and dumps it to a file. Does nuget have a built in way of doing this?

NuGet provides a Get-Package command you can run from the Package Manager Console. It will list the packages and versions that are in the current solution. Example output is shown below:
PM> Get-Package
Id Version Description/Release Notes
-- ------- -------------------------
CommonServiceLocator 1.3 The Common Service Locator library contains a shared interface for service l...
MvvmLight 5.2.0.0 The MVVM Light Toolkit is a set of components helping people to get started ...
MvvmLightLibs 5.2.0.0 The MVVM Light Toolkit is a set of components helping people to get started ...
Newtonsoft.Json 7.0.1 Json.NET is a popular high-performance JSON framework for .NET
Xamarin.Forms 1.3.3.6323 Build native UIs for iOS, Android, and Windows Phone from a single, shared C...
Xamarin.Forms 1.4.4.6392 Build native UIs for iOS, Android, and Windows Phone from a single, shared C...
Xamarin.Insights 1.10.6 Insights for your Apps
Note that this requires the NuGet packages to have been restored. The Get-Package command basically looks at the packages directory to find the used NuGet packages. It does not use the packages.config file.

Related

Why does NuGet package reference incorrect .NET framework/standard?

tl;dr:
I have a .NET Framework 4.7.2 project consuming a NuGet package which supports .NET Standard 2.0. That package, in turn, requires another package which supports .NET Standard 2.0. However, when run, the latter package uses net461 binaries rather than netstandard2.0.
How do I force a NuGet package & its dependencies to use .NET Standard 2.0?
Are there special steps required to consume a .NET Standard package from a .NET Framework 4.7.2 project?
Specifics:
I am trying to get the NuGet package for SparkplugNet (which uses the MQTTNet package) working in a .NET Framework 4.7.2 project - just the basic "How to use" SparkplugB example. Both projects support .NET Standard 2.0. After some debugging (details below), it appears MQTTNet is trying to use code paths specific to .NET Framework 4.6.1, rather than .NET Standard 2.0, and crashing with no feedback whatsoever.
To troubleshoot, I built SparkplugNet and MQTTNet from source. As far as I can tell, the crash comes from hitting .NET 4.5/4.6.1-specific code in CrossPlatformSocket.ConnectAsync(), specifically this line (in context):
await Task.Factory.FromAsync(_socket.BeginConnect, _socket.EndConnect, host, port, null).ConfigureAwait(false)
When I debug, _socket is a System.Net.Sockets.Socket which doesn't appears to have a BeginConnect() method, at least in the source file my debugger pulled. I am not sure why it branches to that code when .NET Standard 2.0 would be a better fit.
Back to a 4.7.2 project consuming SparkplugNet & MQTTNet via NuGet package.... If I look at the reference paths, SparkplugNet is properly pointed at the netstandard2.0 folder, but MQTTNet points to packages\MQTTnet.4.1.3.436\lib\net461\MQTTnet.dll. If I change the hint path manually in the project file, MSBuild appears to pull from the netstandard2.0 folder, but it still crashes. I assume it is the same cause, though I'm having trouble debugging using NuGet packages. Also, I'm hoping for a better solution than hacking hint paths.

Alternate of CoApp (3rd party tool for making NuGet packages from within a build directory)

I am looking to replace CoApp because CoApp is no longer supported. I have explored few alternatives but they seems to be more aimed at installing and uninstalling software than creating and consuming packages in a build environment.
So need any suggestions on alternative of CoApp.

how to install Microsoft.Azure.DocumentDB.Core on portable library

I get error installing documentDB nuget package.
Could not install package 'Microsoft.Azure.DocumentDB.Core 1.2.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile7', but the package does not contain any assembly references or content files that are compatible with that framework.
Any ideas? thanks in advance.
The Core package actually targets NetStandard 1.6, not .Net Core specifically.
NetStandard is a library that acts as API for different runtimes and it's much more powerfull than PCL because it's platform-agnostic:
This means that the DocumentDb.Core package can run on .Net Core 1.0, .Net Framework, Xamarin and UWP.
If you are creating a PCL, I would recommend you to create a NetStandard library instead.
It will let your library support a much wider universe of platforms and the great thing is that, if a new platform comes along that supports NetStandard 1.6 (for example), your library will work without needing to recompile or republish it.
This error message tells us that this assembly Microsoft.Azure.DocumentDB.Core is not supported on portable library. From this assembly nuget site, we know that This client library enables client applications targeting .NET Core to connect to the Azure DocumentDB service. If you want to use Azure DocumentDB library, please try to see if this assembly works Install-Package Microsoft.Azure.DocumentDB

How can I create a Package Management/PowerShellGet/OneGet package from an .exe or .msi?

I can fine a whole bunch of information on how to install packages using Package Management (nee PowerShellGet (nee OneGet)), but I can find nearly zero information on creating those packages.
I did find this which describes how to use the Publish-Module cmdlet to publish a PowerShell module, but I cannot find any information on how to create any other sorts of packages.
Specifically, I would like to create two types: from an .MSI, and from an .EXE. The .EXE I only need installed somewhere on the system, and I need the ability to update the PATH environment variable to allow it to be run by users. For the .MSI, I would ideally like it to be installed (using msiexec), but if that's not possible, I can use other means.
The only remotely-related information I can find is from Chocolatey, which is a system that predates Package Management but that Package Management works with (maybe? sorta? not really clear?). Chocolatey can create packages, but is that really the only way to create packages for Package Management?
Where can I find information on how to accomplish these packaging tasks?
To quote Microsoft:
PackageManagement is essentially a Package Management Aggregator. It creates a unified and consistent PowerShell interface for users and provides a plug-in model at the back end that different installer technologies or package managers can plug-in as providers, using PackageManagement APIs. Each provider further manages one or multiple package sources (repositories) where software packages are stored.
This means there isn't a single way of creating packages, it will depend which Package Management Provider and/or Package Source you are using.
NuGet is widely documented, and so is Chocolatey (which has a plugin available for package management)
If you're looking to install your own private software, as opposed to commercially available software (where you're best off just using one of the existing repositories), you will need to create your own feed/repo. Again this will depend which options you're using. For example, the NuGet documentation on this is readily available.

azure mobile service .net backend not working after nuget packages update

After updating the nu-get packages for a previously working Azure Mobile Service (.Net back-end), I now get the following error when accessing Table Controllers:
An error has occurred.","exceptionMessage":"Object reference not set to an instance of an
object.",
"exceptionType":"System.NullReferenceException",
"stackTrace":"at Microsoft.WindowsAzure.Mobile.Service.Serialization.
SelectExpandWrapperConverter.ODataReflectedTypes..ctor()
at Microsoft.WindowsAzure.Mobile.Service.Serialization ...
Custom Controllers appear to be unaffected.
I've probably missed something obvious, but I can't see it
Any help would be appreciated
Many Thanks
K.
From Henrik F. Nielsen's answer in the MSDN forums:
There are known incompatibilities with the latest version of ASP.NET Web API which was released the same day as our last update. We are working on an update but in the mean time please don't update all your NuGets but only the WindowsAzure.MobileServices.* packages -- they will then include the right dependencies the need.
This is an integration issue with the .NET backend binaries, and it should be resolved soon.
Expanding on #carlosfigueira's answer, it seems that the WepApi 5.2.0 version is not compatible with Azure Mobile Services yet.
I am one of the unfortunate ones who decided to let nuget go to town and update all the packages in the project so here is what I did to deal with this.
Uninstall every nuget package from your mobile service project. Then add them back. Start by using only the Microsoft Azure Mobile Services.NET Backend.* packages - This will pull the currently compatible WebApi 5.1.2 instead of 5.2.0. and other dependent assemblies.
In addition, I was getting a lot of weird redirect binding errors which I believe the tooling added incorrectly - so I commented out all the dependentAssembly tags in the assemblyBindings and then added them back as the mobile service complained. All I had to add back for redirects were Newtonsoft.Json and Microsoft.Owin. YMMV.
I think this may also have something to do with the fact that there are strange interactions between VS and source control plugins since nuget packages sometimes fail because they can't obtain write permissions for packages.config and web.config files.
I am also using a PCL in my service which requires adding the Microsoft.Bcl libraries - perhaps irrelevant but it is what lead me to discovering the underlying error.
Under Tools -> Options -> Projects and Solutions -> Build and Run, set the MSBuild project build output verbosity to Detailed or above to get some insight into what is happening in the process.
[Update 12/24/2014]
I updated something I shouldn't have and everything broke again.
Uninstall all nuget packages. Delete all dependentAssembly elements from the Web.Config file. Save and restart Visual Studio.
Start adding packages back using the following from the Package Manager Console. In my case:
Install-Package WindowsAzure.MobileServices.Backend -Version 1.0.405
Install-Package WindowsAzure.MobileServices.Backend.Tables -Version 1.0.405
Install-Package WindowsAzure.MobileServices.Backend.Entity -Version 1.0.405
Install-Package WindowsAzure.MobileServices.Backend.SignalR -Version 1.0.405
Install-Package WindowsAzure.MobileServices.Backend.Storage -Version 1.0.405
Never touch it again...?