How to update client-side packages in ASP .NET Core 2.1? - asp.net-core

Environment: .NET Core 2.1 running on Ubuntu 18.04
When a new ASP .NET core project is created, a bunch of client-side packages are automatically generated. For example:
$ dotnet new razor
$ ls wwwrooot/lib
bootstrap jquery jquery-validation jquery-validation-unobtrusive
However, I do not see any configuration file that lists these client-side packages.
I believe bower is no longer being used. Plus, I don't see any bower.json file.
I believe libman is not even present on my machine. Plus, I don't see any libman.json file.
Using the command dotnet restore restores only the .net packages listed in .csproj file but does not restore packages under wwwroot/lib directory.
As a quick test, I deleted wwwroot/lib directory and tried various commands. However, none of my attempts was able to restore any packages under wwwroot/lib directory.
Can someone please tell me how are client-side packages managed in ASP.NET Core 2.1 and beyond? How does one upgrade these packages to the latest version?

Most of the files in projects created with the dotnet new command are simply hard-coded in the template. So if you delete them the only way to get them back would be to copy them in from somewhere else.
If you want to manage client-side libraries, then you can use any number of tools to help you such as LibMan or one of the many third-party alternatives.

Related

TinyMCE not installing the default scripts

I have created a asp.net core 2.2 web app and I want to integrate TinyMCE in it. I found out that you can download it as a nuget package but when I installed it, the package did not come with the TinyMCE js template folder(It just said that the package was installed and that's it). How can I install TinyMCE properly?
NuGet does not support copying content files to your project directory any more. This was changed when PackageReference was introduced which is the new default and only supported way to include package references in .NET Core projects.
So while TinyMCE still updates the NuGet package, you will only be able to consume it properly in classic non-Core ASP.NET MVC projects on the .NET Framework.
If you want to use TinyMCE in ASP.NET Core, you should look at other mechanisms to include JavaScript dependencies in your application.
When you take a look at TinyMCE’s “Get TinyMCE” page, you will see a few options. If you already have some npm-based deployment set up, then you should probably get it from npm. Otherwise, you can also just download a static release and copy it into your wwwroot directory. This would actuallly have the same effect as using the NuGet package (if that worked).

Download Nuget Packages for Offline Development/Publishing

Short Question
Is there a way to programmatically download all of the Nuget packages needed to build/publish a solution and output them into a single directory that can be moved to a local Nuget repository?
Some Background
Where I work, most development is done on an air-gapped network (no internet). On a recent project, I was able to develop on our internet-enabled network. This happens to be the first application developed on the internet-enabled network and the first ASP.NET Core app we've ever developed. The solution builds, runs, and publishes just fine on the internet-facing network. I am now trying to move the solution to the air-gapped network, but I am having issues getting all of the dependencies moved over.
At first, the solution wouldn't build because of missing ASP.NET Core nuget packages; so I copied ALL of the nuget packages from the local cache on the machine that I used to develop the application to the local Nuget repository on the air gapped network. Now the application builds, but I can't seem to publish the web project (ASP.NET Core). I'm getting 25+ errors along the lines of:
Unable to find package runtime.any.System.Diagnositics.Tools. No packages exist with this id in source(s)...
Unable to find Nicrosoft.NETCore.App with version (>= 2.1.6)...
Unable to find...
I'm also getting a runtime error "This page cannot be displayed" when I try to run from visual studio (using IIS Express), but I'm not sure if that's a related issue. The unit/integration tests run fine.
I could try manually downloading each nuget package from Nuget.org and moving them over to the air gapped network, but it takes hours to get things moved from one network to another. Is there anyway I can automate the retrieval of all nuget packages required to build/publish a solution so that I can make a single transfer from one network to the other instead moving what I have and waiting to see what breaks? Preferably I'd like a exe or a PowerShell script that could look at a sln file and drop all the necessary nuget packages into a specified directory.
On your internet enabled dev env, you can browse to the root directory of your project and use:
dotnet restore --packages .\package\
This will use the directory called 'packages' as the local cache for the solution and all nuget files will be copied to it.
You can then include the same switch in your build, to ensure that the local cache is used.
dotnet build --packages .\package\
I answered two very similar questions a few weeks ago. Have a look at these answers to see if they help
Command to download a Nuget package with all dependencies to a folder
Is it possible to create a cache of nuget packages for computers without internet?

Do NuGet config file transformations work in ASP.Net Core projects?

I have a NuGet package that I developed, and that package contains web.config.transform file. When I install the package in a regular Asp.Net web project, the content from the .transform file is merged with the web.config (as expected). However, when I try to install the same package in an Asp.Net Core project, the web.config remains unchanged. Do config transforms even work with NuGet + Asp.Net Core?
For similar issue there is a community created cli command at https://github.com/nil4/dotnet-transform-xdt which allows you to transform xdt using command line.
Include above package in tools and you may trigger it post install of your package for applying xdt transform.

Cannot Apply EF7 Migrations - Could not load file or assembly... because I might not know something about ASP.net 5?

I currently have a web project to host database migrations. It was created off an Empty Website. I'm using .net Core only, but I don't think this matters. I'm referencing rc1, not beta. (At this point, I won't show you my project.json, my data context, or the startup.cs file because I think the issue isn't with those.)
I've managed adding a migration with the usual dnx ef migrations add migrationName command from the command prompt.
At the command prompt, I'm sitting at the directory of my web project. When I try to run dnx ef database update, I got
"Could not load file or assembly 'MyProject'..."
I built the project and it compiles without error. I'm accustomed to seeing a /bin folder that has assemblies, where one of the .dlls is MyProject.dll from ASP.net 4.5.x and before. I don't see this folder or such a .dll anywhere in the project. I think the dnx is looking for that but it doesn't exist.
Should I publish the project first? None of the tutorials out there tell me to do that. I tried to anyway, but even in the artifacts folder of the solution, I cannot find any .dlls besides those that come from Microsoft.
There must be something I'm missing or that tutorials don't say, though I'm aware that those tutorials are probably old.
UPDATE
It turns out that I needed to
Right-click on project > Build.
Check "Produce Output on Build". It is unchecked by default. Those tutorials didn't tell us this important bit of information!
After that, all is well! I was able to migrate to the database.

aspnet_client folder within IIS website

I want to know how to permanently remove the aspnet_client folder under some of our websites in IIS.
Our application does not require it, and scripts against these folders fail due to the folder permissions on this folder.
Even the .NET 4 install continues to add this folder. There doesn't seem to be a permanent way to delete the folder, outside of deleting it after registering .NET with IIS, or after installing a new version of the .NET Framework.
Some people say they throw a read-only attribute on the directory, but ... that still keeps the directory hanging about.
See my answer to a similar question, Prevent aspnet_client folder being added to .NET sites
To reiterate that answer:
Check out the MSDN documentation on the ASP.NET IIS Registration Tool (Aspnet_regiis.exe). There's an e and ea command line switch you should be able to use to clean it up after the fact.
You can use Aspnet_regiis.exe to install and remove system client-side script, such as script for client-side validation. Use the -c option to install client script for the version of ASP.NET that is associated with the tool. (Script is installed in the Aspnet_client subdirectory of each IIS site directory.) To remove the client-side script for just the ASP.NET version that is associated with the tool, use the -e option. To remove the client-side script for all installed versions of ASP.NET, use the -ea option.
(Emphasis added.)