Ok, this has happened before, I'm not sure what the deal is.
I go to install this nuget package-
Microsoft.jQuery.Unobtrusive.Ajax
the package is installed "correctly" both using the command line and the GUI. But there is no scripts added to my project?
I had the same problem with MVC6 Grid. At least there I could hack the scripts in.
I found the actual script on Microsoft's CDN page so I can work around this...just wondering if I'm missing something.
Using Visual Studio 2017 and the Project is a Core 2.0 MVC project if that helps. Thanks.
the package is installed "correctly" both using the command line and the GUI. But there is no scripts added to my project?
Since the usage of NuGet for css/javascript libraries is discouraged. You should use Bower or the npm (Node Package Manager) to add the JavaScript libraries instead of using NuGet. The newer project file formats, PackageReferences, only supports files that are in a contentFiles directory inside the NuGet package.
To use the package Microsoft.jQuery.Unobtrusive.Ajax to the .net core project, you need to select your MVC project and add a new file to the project root. While in the template manager (Add->New Item...), search for "Bower Configuration File" or "npm Configuration file".
Then edit the file and add your dependency, i.e.
package.json (npm) or bower.json:
"dependencies": {
"jquery-ajax-unobtrusive": "3.2.4"
}
Note: For package.json (npm), once you save, the file will be downloaded in a directory named "node_modules`. This alone won't be enough, as the required files need to be copied over to wwwroot folder, where they can be accessed when the application runs.
For the detailed info, see NPM, BOWER, NUGET, GULP – The Four Horsemen of ASP.NET CORE Apps.
Related
I am working on a project in VS 2019 and am trying to use the latest winrt/c++ machine learning api. Therefore I conducted the following steps:
Install Microsoft.AI.MachineLearning 1.4.0 NuGet package for specific project
Build the project
Add #include "winrt/Microsoft.AI.MachineLearning.h"
Unfortunately, the header source file is not found. What am I doing wrong?
Cannot open microsoft.ai.machinelearning.h from NuGet package
When you install the nuget package Microsoft.AI.MachineLearning 1.4.0, you should use this
#include "abi/Microsoft.AI.MachineLearning.h"
Actually, Microsoft.AI.MachineLearning.h file exists under the abi folder from your nuget package.
================
Update 1
I have reproduced your issue in my side. And it seems that there is no such error in my side. I just create such project followed by the above document, then install that nuget package-->build the project and after that, I can call
`winrt/Microsoft.AI.MachineLearning.h.
And the winrt c++ project just puts such file into Generated Files folder during build process based on the function of the project.
So it is a quite strange behavior, and I suggest you could follow these steps to troubleshoot it:
Before all, you could check this document first.
1) First, close your Windows Console Application (C++/WinRT) project, delete .vs hidden folder, any output folders like Debug or Release under the solution folder and project folder.
2) Then restart your project and make sure that Microsoft.AI.MachineLearning 1.4.0 NuGet package is installed.
Then rebuild your project and make sure that build process is successful.
3) Then I can call #include "winrt/Microsoft.AI.MachineLearning.h".
If these steps do not help, I think VS or your current project itself has something wrong.
please try to disable any other third party extensions under Extensions-->Manage Extensions and then restart VS to test it.
Or just create a new WinRT C++ project to test whether the issue happens in the new project.
Is it possible, as part of a CI process for NuGet package creation, to install a newly created package to a project, residing in the repository? So that the installation can be tested.
It's easy to do using Visual Studio UI, but how to do it on a newly created azure pipeline worker automatically?
Install NuGet package on the project in Azure Pipeline
I am afraid it is impossible to install NuGet package on the project in Azure Pipeline.
Because NuGet CLI install command line just Installs a package into the current project but does not modify projects or reference files (packages.config).:
It is like the command line nuget restore, just download the packages not install it.
To install the package to the project, we need modify the project file via access to visual studio objects:
https://github.com/NuGet/Home/issues/1512
So it should be impossible to install NuGet packages out of Visual Studio, check my another thread for some details.
Besides, we also do not recommend to install NuGet package in Azure Pipeline. If we install a newly created package to a project automatically, it will use the scripts to modify our Repos, which is not recommended and safe.
Personally, the correct process is:
Create the new package in the Azure pipeline.
Publish the new package to the Artifacts or any other nuget feed.
Install/Update the new package to the project with Visual Studio and test it.
Update the new package version to the Repos.
Hope this helps.
The NuGet.Client repo has a bunch of tests that install packages into test projects and assert various things. I know of a whole lot of PackageReference tests, but can't remember any packages.config tests. Using the .NET CLI it's easy to script a lot of it, but depending on what you want to do, you might need to write some code to manipulate XML files.
Here's a bunch of useful commands totally written from memory and therefore might not work as is, but it'll get you started:
# create a new .NET Core console app. You'll need to edit the csproj to test different frameworks
dotnet new console
# create nuget.config file
dotnet new nugetconfig
# add a local folder as a package source
nuget sources add -configfile nuget.config -name local -source ..\newPackages
# set the global packages folder to a empty/temporary directory, so the test package
# doesn't pollute the agent's global packages folder
nuget config set -configfile nuget.config globalPackagesFolder gpf
# add the latest version of the package to the project in the current directory.
# use --version to specify a version
dotnet add package MyTestPackage
Since SDK style projects are so short and simple, you may be better off just hardcoding the contents in your code and write them to disk for your tests. It's what we (NuGet.Client) do.
We have plans to eventually move the config options to the dotnet cli so that you won't need to download nuget.exe, but it's really low priority since it's so easy to workaround. nuget.exe works on mono on Linux and Mac, or just hardcode the conents of the config in a string in your test and write it at runtime.
This will only be useful for you if the things you want to test are not impacted by package compatibility issues with PackageReference vs packages.config. However, given the future of .NET is SDK style projects, and SDK style projects don't support packages.config, you can try justifying it by saying it's the future.
I'm trying to get Signalr from Nuget and have installed every package I can find, but can't seem to find the client JavaScript files that should be included. I've run the command from the package manager (in Visual Studio 2017)
npm install #aspnet/signalr
But alas, there is no /lib/signalr/signalr.js file anywhere. The Client stuff should be there. Where can I download this?
Found it! What the docs do not tell you is that the scripts are dumped into the following folder in the solution folder
node_modules\#aspnet\signalr\dist\browser
and there it was signalr.js (and the minimized version as well)
You create a folder called signalr under wwwroot/lib and place it there.
While installing Nuget package like bootstap using visual studio 2017, for example, nuget manager installing the css files of bootstrap package in "~/Content/" directory while i prefer it to be located in "~/Content/css".
i know that i can move the files manually and to change the reference manually but then, i will need to do it again every time i am updating the package using visual studio nuget package manager.
i am wondering, if there is an option to tell every package where to install the relevant files so it will be remembered for later updates.
i am wondering, if there is an option to tell every package where to install the relevant files so it will be remembered for later updates.
I am afraid there is no such option to tell every package where to install the relevant files. According to the conventions for .nuspec file:
The convention for content is:
Think of the content folder as the root of the target application that ultimately consumes the package. To have the package add an image
in the application's /images folder, place it in the package's
content/images folder.
Just like Matt comment, "The location of the files is determined by the NuGet package itself", so there is no such option to tell every package where to install the relevant files.
Is it possible to update a "tools-only" Nuget package via the command line?
By "tools-only", I mean a package that does not contain a "lib" or "content" folder (according to the definition on the Nuget site), and contains scripts or tools rather than libraries that are referenced by Visual Studio Projects. A typical use is for tools that assist with build processes.
I am able to add tools-only packages in Visual Studio by managing the Nuget packages at the Solution level. That will download the package correctly, and also let me see and install updates to it.
But I've not been able to get the "update" command of the "nuget.exe" command line app to do the package update. It appears to drive all updates from the project files... but the package is not referenced by a project because it's not a code library.
I understand the focus of Nuget is code libraries, but the doco does make mention of tools packages... Given that it can be done within Visual Studio, I'd have thought the same should be possible on the command line.
E.g.
Tool package "A" (no lib, just tools folder)
In VS in project "B", manage Nuget packages on solution and install A
(Will download, and create ".nuget" folder with packages.config)
Release new version of "A"
In this scenario, I can see and install the update within VS, but cannot get the right command line to install the update.