I'd like to include custom Package Manager Console commands with my NuGet Package. Just like EF-Core is doing recently to generate the context for example.
How can this be done without having to use the default folder "... Documents\WindowsPowerShell\NuGet_profile.ps1"?
I want to generate classes via console so I do not have to develop a Visual Studio extension for it.
Thank you!
You would pack .pds1/.psm1 files into a tools directory inside the NuGet package. Which are automatically available inside the Package Manager Console (the tools folder will be added to the PATH environment variable).
You can download and inspect the Microsoft.EntityFrameworkCore.Tools for reference, since this is the package that provides the Entity Framework Core commands.
Related
I have the situation where our code base is like so:
/Gui/
/Product1/
/Calc engine/
/Core/
/Product2/
All of these projects are loaded into a Global solution file in Visual Studio.
I want to extract Core to it's own repo and allow different branches of this repo to load different versions of it. I cannot just use references to the binaries as engineers want to be able to debug the core code when running the Products so I have to be able to bring the entire Core codebase in.
Originally, I intended to use git submodules but I am investigating whether Nuget might be a better solution. I have removed /Core/ to it's own repo and created a Nuget package of the Core directory (it contains about 20 different C# projects).
Is there a way I can input this Nuget package into the Global Solution? It would need to put the code into the same directory as it used to rather than a package director.
Is there a way I can input this Nuget package into the Global Solution? It would need to put the code into the same directory as it used to rather than a package director.
You can change the Package Management to "Pakcage.config" in Options\Nuget Package Manager. The package will be stored in solution directory.
and right-click the solution in solution explorer then click "Manage Nuget Packages for Solution"
In Visual Studio (Enterpris 2019) using NuGet Package Manager
is it possible to report all references used per project of the solution?
I am esp. interested in the NuGet packages and I noticed that my local repositories
get bloated with folders of older package versions.
Most of them empty with files that are ignored by git.
So a listing of all references actually in use would be helpful.
E.g. via Package Manager Console.
By Package Manager Console, it could be done with it.
You should open the whole solution on VS2019, and then open Package Manager Console, then type:
Get-Package | Select-Object Id,Version,ProjectName
It will list all nuget references and their version per project of the solution.
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 am trying to create a button which will automatically run few powershell commands which are imported in nuget package (tools in nuget package)
I found out how to add custom button in this question: How can I add a custom command to Visual Studio?. But I cannot find out how to run from this command in package manager console.
So is there a way to add custom command button to visual studio, which will start and run command in package manager console?
Using a custom command described by link, you can run only external tools. In your case, you can run NuGet command line utility. First, you need to download nuget.exe. Then you have to add a custom command, arguments for it and initial directory in External Tools dialog. You can use solution variables (e.g., $(ProjectFileName), $(SolutionDir)) for arguments and initial directory fields. You can use bat file to run few commands.
Unfortunately, the NuGet command line utility has fewer features than package manager console. I don't know, is it enough of these features to solve your issue?
To use all features of NuGet and to integrate into Visual Studio, you can implement your VSPackage. From VSPackage you can add at any place of Visual Studio the custom command (as a button or menu item). When the command launch (user clicked your button), you can call any method of NuGet API inside Visual Studio. This way requires time to develop and not so simple.
I'd like to create a custom MSBuild task and distribute it as a NuGet package. To enable my task, the visual studio proj file should be modified.
Is it possible to add my code sections to the proj file when installing the NuGet package?
You can do this using Powershell. It is possible to unload you project, edit the project file and reload the project.
Scott Hanselman did this here: http://channel9.msdn.com/Events/MIX/MIX11/FRM09
If you find a package that does what you want, you can open the nuget package using ZIP and see the powershell scripts. Thats a good starting point to learn that stuff.
hope that helps
I think you are better off using the NuGetPowerTools package as answered in this question:
Adding a custom build step with a nuget package
This package handles all the Visual Studio automation.