create NuGet package with custom PMC commands - c#

I was wondering how can I get to develop a toolset that I can then run using package manager console commands to modify my project (analyze or generate code).
Someting like Microsoft.EntityFrameworkCore.Tools that adds add/remove-migration etc. commands.

We can see all commands to interact with NuGet in Package Manger Console from this link. Unfortunately, there is no command to create a nuget package.
( https://learn.microsoft.com/en-us/nuget/reference/powershell-reference )
You can try this command “dotnet pack” in PMC, it effectively created the nuget package in my test.

Related

Cannot add package to visual studio. (System.Management.Automation)

Trying to add System.Management.Automation package to my project in visual studio because I want to run powershell commands through my code, but am getting the error:
The project does not support adding package references through the add
package command. My dotnet --version is: 7.0.102
I inputted
dotnet add package System.Management.Automation --version 7.3.2
into the package manager console, and was expecting it to work as normal when adding a nuget package, however instead received the error
Error while adding package 'System.Management.Automation' to project
'C:\Users\userone\source\repos\blackjack21\blackjack21.csproj'. The
project does not support adding package references through the add
package command.
No idea what to do.

Nuget package installed even if it is not included in project [duplicate]

I want to list down all the nuget packages along with its dependencies recursively.
Project is in VS2017 and .NET Core.
I tried with Get-Package -ProjectName "Your.Project.Name" it displays all the nuget packages in project. I want all the dependencies also printed.
You can use the dotnet cli: dotnet list package --include-transitive. The dotnet-outdated global tool probably has similar functionality.

How to create an App package for WinUI Projects?

I can create my msbuild app package for WinUI via manual app package creation method.
But, I need to create a App package through command line.
msbuild mysolution.sln /t:Rebuild /p:Configuration=Release;OutDir=D:\#Development\CI\AppPack;Platform="x86|ARM"
When I execute the above command in Powershell, I am facing the below Errors.
So, suggest me any solution for create an app package for WinUI through command line.

Is one dll can be both dotnet tool and nuget?

Creating a dotnet tool is like creating a nuget package. We create it by dotnet pack command and publish him to nuget feed.
But we can't use it as nuget package in our C# project, although it is a nuget!
Can I create a one Console Application project and publish it as dotnet tool, and then use it as nuget package in a C# project?
Publish your tool as NuGet package, add the dir you published to to the NuGet soruces (VS:Tool>Options>NuGet>big-green-plus-button).
Open the NuGet package Manager in the Project you want the use the NuGet package and select your source, wait for NuGet to load, and then install the NuGet tool you published

Managing References in Visual Studio 2012

Please help me understand: I have a Visual Studio project. It has Nuget package manager enabled. I install several libraries. The library versions are shown in packages.config. Each library has a corresponding entry in References.
Now, say I want to change the library version from, say, 2.2.0 to 2.1.0. How I do this? At first I assumed you could just change the version number in packages.config. But when I do this, and get Nuget to download an earlier version of the library, the project references are not changed.
Do I have to manually remove each and every reference in the project to 2.2.0 and replace it with 2.1.0?
I get the feeling I'm "doing it wrong", but there doesn't seem to be any examples I can find of anyone doing it right.
Thanks for any help!
Using jQuery as an example:
If you want to rollback to a previous version you can run the Uninstall-Package jQuery and Install-Package jQuery -Version 2.1.0 commands from the package manager console.
Also, the package nuget page will have a list off all the versions available. EX: jQuery
All of this and more available in the nuget Docs
You can't simply change the version in the config file since your project still holds a reference to the binaries, so the binaries need to be replaced too.
Now, I'm not entirely sure if there is a "downgrade" Powershell command but you can certainly uninstall the specific package and then install a lower version. By using the Package Manager Console. So from within Visual Studio:
Go to the View menu -> Other Windows -> Package Manager Console
Select the Default Project from the dropdown list
Then run the following command to uninstall the package
The command to uninstall is...
Uninstall-Package YOUR_PACKAGE_NAME
To install a lower version, run this command...
Install-Package YOUR_PACKAGE_NAME -Version 1.0
These and other commands are very well documented in The Package Manager Console Powershell Reference
Uninstall-Package Command
Install-Package Command

Categories