I am trying to install knockoutjs and typescript in a .net core app via Nuget.
It shows in Packages but doesn't install anything in a scripts folder as has previously in asp.net.
What am I missing?
TL;DR ASP.NET Core no longer works in that way (packages copying javascript/css content into your project). You need to adapt your workflow.
.NET Core projects only work in SDK-style projects, and SDK style projects only use NuGet's PackageReference, not packages.config. The docs on migrating from packages.config to PackageReference list one package compatibility issue as not supporting the content folder, which is how in packages.config those assets are copied into your project on package install.
I can't find a doc listing recommendations for ASP.NET Core apps, but my understanding is you can either use LibMan, or use NPM, which is in line with basically the rest of the web development industry outside of .NET has been doing. If you use the new project templates to create a new ASP.NET Core Angular or ASP.NET Core React app, you'll see they create a ClientApp folder that uses npm and all the official react/angular CLI tools. The MVC template has copies of jQuery and bootstrap, without an obvious way how to update them.
might be some unsync, remove the packages folder from the solution and restore the packages again. It will fix the issue. Also check the output window, that will show the list of errors.
It shows in Packages but doesn't install anything in a scripts folder
as has previously in asp.net.
First, I agree with zivkan. It is a feature of PackageReference Nuget Management format.
VS has two format to manage nuget packages: Packages.config and PackageReference.
Since new sdk format projects(Net Core and Net Standard) only use PackageReference to manage nuget packages,it will be very different from the effect reflected by the packages.config package management format.
When you use Content files from the nuget packages with PackageReference, it will lose files from the Scripts folder.
Just as this document said, it has such compatibility issues.
Actually, you can enter C:\Users\xxxx\.nuget\packages\knockoutjs\3.5.1 and find there is a folder called Content, Nuget will copy the content of that folder into your project when you install this nuget package.
But Content folder can be recognized by Packages.config format, and as far as I know, ContentFiles folder is used in PackageReference to add the content into your project. So in your situation, the nuget package should include ContentFiles folder at the same time. See this official document.
But the knockoutjs nuget package does not have contentfiles folder. That is why net framework projects with packages.config has the content files while new sdk projects does not have it.
And this behavior change can only be effective when you create the nuget package, so you ca n’t make any kind of change, you can only contact the author of the package to make this modification, and let him add this function as soon as possible to apply to the new SDK format project.
Suggestion
So So for now, you can try these:
1) you can either manually Add the content file from C:\Users\xxxx\.nuget\packages\knockoutjs\xxxx\Content to the project by Adding Existing Items.
2) roll back to use Net Framework projects with packages.config.
3) contact with the author on this link.
Related
I'm trying to use Bootstrap in my ASP.NET MVC5 project (I'd like to use .NET 5, but Visual Basic is not fully supported yet.)
I installed the latest NuGet package, but no folders/files were added to my project—only the package itself under the References node.
I found this extensive answer, but it's somewhat dated and it addresses a project architecture of ASP.NET Core. I added the suggested Package.json file, but no folder node_modules was added anywhere in my project.
How do I get started using the Bootstrap NuGet package in my MVC5 project?
--EDIT--
I'm using PackageReference, not Packages.config.
For Bootstrap is a client-side library,If you download by Nuget Package Manager, you can find it in the %UserProfile%\.nuget\packages directory. You could copy and paste it to your project.
Actually I suggest you could use LibMan for client-side library.
Here is the steps you could follow:
Create the folder wwwroot/lib;
In Solution Explorer, right-click the project folder in which the files should be added. Choose Add > Client-Side Library.
Search for bootstrap#5.0.2 like below:
Click the Install button to download the files.
Reference:
Use LibMan with ASP.NET Core in Visual Studio
Note:
The js and css are in wwwroot/bootstrap/dist/.
I need to use native c libraries in my library(that supports several Core TFs and .net framework) which is published via nuget. I configured it via .csproj file and runtimes folder. But I noticed that when I consume my NuGet via dotnet add package .. in some cases, the native libraries are not copied into the expected folder after consuming, however when I use the VS UI Nuget package manager->Manage Nuget Packages for Solution, all files are placed into correct places.
So, I assume that Nuget package manager makes more steps than just call dotnet add package .., but it's unclear what exactly happens, any help will be appreciated.
Actually, dotnet add package does the same effect as Nuget package manager UI in VS IDE. They simply install a Nuget package into your project and there is no difference. No additional operations will be performed. Like add some xml node in
So I think there is something else wrong in your project.
Please check under tips to troubleshoot your issue:
1) clean nuget caches first or just delete all cache files under C:\Users\xxx(current user)\.nuget\packages.
2) And if the runtimes folder does not exist under your project, I think it is controlled by dependency assets. Like ExcludeAssets=runtime or native. It will prevent the function of runtimes folder. Please see this official document.
So after you finishing installing the nuget package, you should check your csproj file, and make sure that there is no such like
<ExcludeAssets>runtime;native</ExcludeAssets>
under PackageReference node.
If there is any this node, please delete it.
3) delete bin and obj folder. Then rebuild your project to test again. Or if you use dotnet command line, you should additionally add dotnet build command. In my side, I run dotnet build -p:platform=xxx;Configuration=Release.
I have a project with a few front-end frameworks obtained via and managed by Nuget (Twitter Bootstrap, jQuery, jQuery UI ...).
I want to keep the files in my project, but remove them from Nuget's grip (I don't like the way Nuget organizes these files).
When I un-check the project for a library Nuget removes all the files it had installed, unless I've editted them (e.g. I over-wrote bootstrap.css with a customized version from getbootstrap.com).
As I do this from time-to-time, instead of backing up the /Content and /Scripts directories and adding back in the relevant files after removing the library from Nuget, I'd like to be able to dissociate all files of a particular library from Nuget at once without removing them from the project's directories. Is that possible, by either the GUI or the console?
I don't know if this issue is specific to a version(s) of Visual Studio, but mine is VS 2012
Can you elaborate for the part of "I don't like the way Nuget organizes these files"? If you remove NuGet from the picture, the good things that it does for you (detection of package updates, automatic package restore etc.) will be gone.
If you absolutely need to do this, one possible hack would be deleting packages.config from the project.
I have a solution with two projects:
.NET application
WiX setup project.
I know, that it is possible to refer to project output in WiX source ($(var.WindowsFormsApplication1.TargetFileName)).
Now I've added a NuGet package reference to my .NET application. So, I want to bring NuGet package content into my setup.
Is there any way to do this instead of adding files manually?
I don't believe there is any linkage. I know what nuget is but I haven't used it much because it's more about brining your .NET dependencies into scope then software distribution. Depending on how nuget lays the files down you might be able to do something like $(var.SomeProject.TargetDir)nuget_fetched.dll.
This is assuming that SomeProject uses nuget in such a way that the references are copied locally and available in the Outdir of the project.
I wrote a Resharper live template to cut out a lot of the typing involved in adding the files, but essentially I've just added the files manually. Creating a Wix component per nuget package keep things neat.
Can anyone share with me how to (or where I can find how to) install NuGet packages automatically when I create a new project based on my custom project template in Visual Studio 2010?
I am creating a new project template for a project that uses a couple NuGet packages by default. I've read the documentation on the NuGet site but this is not acceptable in that I want to reference an existing package if it's already installed in the project.
In other words, if I embed package v1 in my template (VSIX) but version 1.1 has already been installed in the solution, I want NuGet to reference version 1.1 instead of putting v1 into the solution and forcing the developer to update the package.
Is this possible? And, if so, how?
NuGet 1.5 now supports this feature without requiring that you build an ASP.NET MVC 3 project template.
http://blogs.msdn.com/b/marcinon/archive/2011/07/08/project-templates-and-preinstalled-nuget-packages.aspx
This supersedes the post that I wrote. :)
Check out this post here:
http://haacked.com/archive/2011/06/06/creating-a-custom-asp-net-mvc-project-template.aspx
The article mentioned that the NuGet packages need to be on your machine, however this should change in the future (if it hasn't already).