Since a recent update of Nuget Package Manager (from 2.9 to 3.2.0 I guess), installing package via nuget doesn't add addition files of the package anymore. It just adds the libraries only, update the "project.json" and something like that.
For example: Installing MVVMLight to a project will add Models, ViewModels and Views folder to project. Also, it will add a MainViewModel.cs, ViewModelLocator.cs to ViewModels folder. Now none of these files/folders are added to project.
Any suggestion will help
Since Nuget 3.1 this is no longer supported: https://docs.nuget.org/release-notes/nuget-3.1. One of the main reasons is that packages can copy in files on install, but you're not sure what to do with it on uninstall (as content might have changed manually). But do note that there's an open issue to maybe re-enable this functionality.
Laurent Bugnion of MVVM Light is aware of this issue as well:
Caution: Full package in Windows 10 Universal applications (UWP)
There is a known issue when you install the “mvvmlight” package in
Windows 10 universal applications. The Nuget team unfortunately
changed the way that Nuget works for this framework, and it doesn’t
allow installing additional files, or running scripts anymore. Because
of this, installing the “mvvmlight” package in Windows 10 UWP
applications creates the exact same result as installing the
“mvvmlightlibs” package. Because running a script is not allowed, it
is not even possible to warn the user.
I will publish more detailed information on how to add the scaffolding
to a Windows 10 UWP application manually. Stay tuned.
As of today, he didn't post a full guide yet, but you could try to run the packaged powershell script manually.
Related
Background:
I have created a class library for .net core (targetting v2.2), and I have a .net core application as well (targetting v2.2).
I am trying to export the library as nuget package and install it in my application.
Here is the dependencies for my library
I am able to export it as nuget package and for now I am storing it in local nuget repo.
But when I try to install this library package in my application it's not getting installed due to package version conflict for Microsoft.Extensions.Logging. Here's package manager console output.
Issue:
I have specified the exact version for Microsoft.Extensions.Logging i.e. [2.2.0] as we could confirm that in the screenshot showing dependency for my library, then why it's getting resolved to version 3.0.0?
How could I resolve this issue?
Details about the environment:
NuGet product used (Package Manager Console): Package Manager Console Host Version 5.3.1.6268
VS version (if appropriate): Microsoft Visual Studio Community 2019 Version 16.3.8
OS version (i.e. win10 v1607 (14393.321)): Windows 10 Enterprise Version: 1809
How could I resolve this issue?
To resolve the strange behavior in your side, you should clean the nuget cache before installing that package in your current project.
(To make sure the cache is cleaned up, I suggest you go %userprofile%\.nuget\packages to check if there exists Com.lib folder within the Packages folder)
I have specified the exact version for Microsoft.Extensions.Logging
i.e. [2.2.0] as we could confirm that in the screenshot showing
dependency for my library, then why it's getting resolved to version
3.0.0?
I think the one(Com.Mylib) you want to install is not the first one you pack. I mean that you may actually build and pack several different Com.Mylib package with different content. And all of their names is Com.lib.1.0.0.nupkg.
Nuget stores all nuget cache in %userprofile%\.nuget\packages. So if I once install one PackageA in any project. The cache of PackageA is stored there. And if I open a new project trying to install the PackageA with same version(1.0.0), it actually installs the one from cache. So we will meet this strange behavior:
Nuget can recognize the Com.lib package depends on other 2.2.0 packages. But when it tries to install that package, it finds the package has existed in cache. Then he tries to install the one from cache, and I guess content of the one in cache is different from your latest one, then the issue occurs.
Suggestions:
1.When developing locally, use project reference instead of Nuget packages.
2.If you need to test the nuget package every time after packing, please make sure the package version has increased.(1.0.0=>1.0.1=>1.0.3... or beta-1.0.12, preview-xxx)
3.If you have special reason do use same version 1.0.0, please clean the cache to avoid previous cache affects current project.
Hope all above helps :)
I'm using Visual Studio 2017, building a .Net framework (not core) v4.6.1 ASP.Net MVC project and when I added packages to my single project inside my solution the packages are seemingly restoring/installing to multiple different locations. I am installing packages from multiple feeds, some are internal to my company and others are public.
Some packages are located at my solution root and others seemingly are landing at %userprofile%.nuget\packages\
One package even installed and its hintpath was in a completely different location from the two of them. The package was installed there but I don't know why it didn't install to what I consider the solution's local package folder.
I'm not sure if these are the right questions to ask yet, but these are what I'm trying to answer for now:
For VS2017, .Net framework, ASP.Net MVC what is the default package install location?
How do I specify which feed a package comes from for CI/CD purposes?
Does NuGet look for packages already installed on my computer?
If yes, where does NuGet look for packages and where can I find its list of locations it looks for.
Thanks!
1.For VS2017, .Net framework, ASP.Net MVC what is the default package install location?
It depends on which package management method you using. If you are use package.config, the default package install location is solution root, if you are use PackageReference, the default package install location is %userprofile%.nuget\packages\. That is the reason why you added packages to single project inside the solution the packages are seemingly restoring/installing to multiple different locations. You can unload and edit your project, check the project file .csproj, you will find following:
<ItemGroup>
<PackageReference Include="xxxxx">
<Version>x.x.x</Version>
</PackageReference>
</ItemGroup>
To resolve this issue, you can accept the advice of Lex. If you want to unify, make the choice and change the files. You can uninstall those packages which using PackageReference(or package.config), then change the nuget settings(Tools->Options->NuGet Package Manager->General->Default package management format->Packages.config), then reinstall those packages, make sure they use a uniform form.
2.How do I specify which feed a package comes from for CI/CD purposes?
You can not do such things and you do not need to do things. As we know, when we install nuget packages from multiple feeds, all the packages are downloaded to the local host, Visual Studio will use those packages on the local, Nuget does not care which feed it comes from.
3.Does NuGet look for packages already installed on my computer?
4.If yes, where does NuGet look for packages and where can I find its list of locations it looks for.
Yes, you can use the command line nuget locals all -list to find its list of locations.
See Managing the global packages, cache, and temp folders for some more details.
Hope this helps.
I am new in WPF application development and I came across the Material Design package, I am using Visual Studio 2015 Enterprise.
Every time I want to create a new WPF application I always go to
Project -> Manage NuGet Packages and install the MaterialDesignThemes package for that specific project and when I am working on another project I need to do the same process again.
Is possible to only install this package once and somehow use it (or reference it) on all projects that I am creating as opposed to installing it with each and every new project I create?
I hope my question makes sense and I am asking this for the sake of being able to develop new material design WPF applications offline.
They ask to use nugget to keep the package updated that way you can check versions and so on. But you can download the source code from GitHub and keep it on your machine or server you use it for. That way you can refer it from your machine and don’t need to download for every project you work.
Project source: https://github.com/ButchersBoy/MaterialDesignInXamlToolkit/releases
In my opinion, I highly recommend download from nugget repository because it is easy to maintain and anyone else that code and the same project will find the package over there.
Create a Project Template.
VS2015: https://msdn.microsoft.com/en-us/library/xkh1wxd8.aspx
VS2017: https://learn.microsoft.com/en-us/visualstudio/ide/how-to-create-project-templates
Another way of quickly installing nuget packages is using the Package Manager Console and use the install-package command. e.g. install-package materialdesignthemes
I was working with Unity and Hololens and tried to establish connection to Azure Iot Hub via MQTT protocol. Microsoft provides a tutorial for getting started with Azure IoT Hub in C#, but unfortunately, I encountered a problem with the tutorial:
In the picture above, I have selected Microsoft.Azure.Device NuGet package for installation. I have tried version 1.0.0 and also the latest one available, 1.2.4. The projects were automatically generated by Unity and that is probably the reason, why I do encounter this problem. Which problem? After I try to install the selected NuGet, I encounter the following error:
Could not install package 'Microsoft.Azure.Devices 1.2.4'. You are
trying to install this package into a project that targets
'.NETFramework,Version=v3.5,Profile=Unity Full v3.5', 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.
I was like, "Hmm, I must have wrong .NET framework version. I wonder if I can change that..." I tried to go to project properties like this
Microsoft advises changing .NET framework from Properties context menu item:
https://technet.microsoft.com/fi-fi/library/bb772098(v=vs.90).aspx (4.24.2017)
https://msdn.microsoft.com/en-us/library/bb398202(v=vs.100).aspx (4.24.2017)
However, this feature must be blocked by something, because the view that is supposed to open flashes white and disappears immediately. I suppose Unity doesn't like people tinkering with project properties, but what else can I do? Incompatible .NET framework issue needs to be resolved, so that the NuGet package can be installed, but how do I do that?
In short, how to install Microsoft.Azure.Devices NuGet package for Unity?
Sorry, this isn't possible due Unity's restriction to .net 3.5.
To be exactly, they use a custom version of mono-2.
You could try the new (experimental) .net 4.6 settings in Unity 5.6.
https://forum.unity3d.com/threads/upgraded-mono-net-in-editor-on-5-5-0b4.433541/
I'm trying to automate adding NuGet packages to project on a remote server that doesn't have Visual Studio (nor any build servers) installed. I do know how to use NuGet.exe from my C# code, but this executable only downloads packages and doesn't do any other required work (adding references, executing ps scripts etc). What do I do in order to fully install a package?
Note: I don't need to update a package for my own app, I need to add a package to an arbitrary .csproj file on the server. I'm building a Web-based .Net IDE, and need my users to be able to add packages to their projects.
I see two possibilities: one is using some kind of functionality not present in NuGet.exe, but ratherin some other library (maybe a VS addin), but I don't know where to look for it. The other is to simulate some kind of NuGet Powershell console and send commands to it, but again, I don't know how to do that.
You might want to consider SharpDevelop.
Installing NuGet Packages outside of Visual Studio an article about the functionality you are trying to achieve (written by Matt Ward, one of the project contributors) says:
Since NuGet uses PowerShell the simplest approach was to extend the
existing PowerShell cmdlets included with SharpDevelop. Now you can
write a few lines of PowerShell script to install a NuGet package into
a project that has never had a NuGet package before, have the project
itself updated and any package PowerShell scripts run. All this from
the command line without Visual Studio open.
Just to add an additional answer in-line with Alex's post about SharpDevelop, you have a couple different options.
Use Nuget.exe (Related Blog post)
NuGet Addin for MonoDevelop and Xamarin Studio (see GitHub)
ASP.NET Pages using WebMatrix (see this video)
All of this info is from the Nuget FAQ.