首页 > 其他分享 ># NuGet包管理

# NuGet包管理

时间:2024-04-17 20:24:36浏览次数:12  
标签:nuget nupkg Package Elmah 管理 NuGet 推送

NuGet包管理

目录


NuGet 简介

hand-right NuGet 简介

在 Visual Studio 中使用 NuGet 包管理器安装、更新、卸载和管理包

通过 Microsoft Visual Studio for Windows 中的 NuGet 包管理器 UI,可轻松安装、卸载和更新项目和解决方案中的 NuGet 包。

hand-right 使用 NuGet 包管理器在 Visual Studio 中安装和管理包

NuGet常用命令

hand-right dotnet nuget

hand-right PowerShell 参考

1. 推送包到服务器

dotnet nuget push

命令:

dotnet nuget push [<ROOT>] [-d|--disable-buffering] [--force-english-output]
    [--interactive] [-k|--api-key <API_KEY>] [-n|--no-symbols]
    [--no-service-endpoint] [-s|--source <SOURCE>] [--skip-duplicate]
    [-sk|--symbol-api-key <API_KEY>] [-ss|--symbol-source <SOURCE>]
    [-t|--timeout <TIMEOUT>]

dotnet nuget push -h|--help
dotnet nuget push -k 密钥 -s nuget服务地址 nuget包地址

示例:

# 将E:\LinkC\Desktop\cef.redist.x86.109.1.11.nupkg 推送到 http://192.168.10.144:9001/v3/index.json
dotnet nuget push -k qwerty123456 -s http://192.168.10.144:9001/v3/index.json E:\LinkC\Desktop\cef.redist.x86.109.1.11.nupkg

# 将 foo.nupkg 推送到 NuGet 配置文件中指定的默认推送源(使用 API 密钥):
dotnet nuget push foo.nupkg -k 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a

# 将 foo.nupkg 推送到官方 NuGet 服务器,以指定 API 密钥:
dotnet nuget push foo.nupkg -k 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a -s https://api.nuget.org/v3/index.json

# 将 foo.nupkg 推送到自定义推送源 https://customsource(指定 API 密钥) :
dotnet nuget push foo.nupkg -k 4003d786-cc37-4004-bfdf-c4f3e8ef9b3a -s https://customsource/

# 将 foo.nupkg 推送到 NuGet 配置文件中指定的默认推送源:
dotnet nuget push foo.nupkg

# 将 foo.symbols.nupkg 推送到默认符号源 :
dotnet nuget push foo.symbols.nupkg

# 将 foo.nupkg 推送到 NuGet 配置文件中指定的默认推送源(超时 360 秒):
dotnet nuget push foo.nupkg --timeout 360

# 将当前目录中的所有 .nupkg 文件推送到 NuGet 配置文件中指定的默认推送源:
dotnet nuget push "*.nupkg"

# 将所有 .nupkg 文件推送到 NuGet 配置文件中指定的默认推送源,即使 HTTP(S) 服务器返回“409 Conflict”响应也是如此:
dotnet nuget push "*.nupkg" --skip-duplicate

# 将所有 .nupkg 文件推送到 NuGet 配置文件中指定的默认推送源,即使 HTTP(S) 服务器返回“409 Conflict”响应也是如此:
dotnet nuget push "*.nupkg" --skip-duplicate

# 将当前目录中的所有 .nupkg 文件推送到本地源目录 :
dotnet nuget push "*.nupkg" -s c:\mydir

2. 安装包

Install-Package(Visual Studio 中的包管理器控制台)

命令:

Install-Package [-Id] <string> [-IgnoreDependencies] [-ProjectName <string>] [[-Source] <string>]     [[-Version] <string>] [-IncludePrerelease] [-FileConflictAction] [-DependencyVersion]    [-WhatIf] [<CommonParameters>]

例如:

# Installs the latest version of Elmah from the current source into the default project
Install-Package Elmah

# Installs Glimpse 1.0.0 into the MvcApplication1 project
Install-Package Glimpse -Version 1.0.0 -Project MvcApplication1

# Installs Ninject.Mvc3 but not its dependencies from c:\temp\packages
Install-Package Ninject.Mvc3 -IgnoreDependencies -Source c:\temp\packages

# Installs the package listed on the online packages.config into the current project
# Note: the URL must end with "packages.config"
Install-Package https://raw.githubusercontent.com/linked-data-dotnet/json-ld.net/master/.nuget/packages.config

# Installs jquery 1.10.2 package, using the .nupkg file under local path of c:\temp\packages
Install-Package c:\temp\packages\jQuery.1.10.2.nupkg

# Installs the specific online package
# Note: the URL must end with ".nupkg"
Install-Package https://globalcdn.nuget.org/packages/microsoft.aspnet.mvc.5.2.3.nupkg

3. 更新/重新安装包

Update-Package(Visual Studio 中的包管理器控制台)

命令:

Update-Package [-Id] <string> [-IgnoreDependencies] [-ProjectName <string>] [-Version <string>]
    [-Safe] [-Source <string>] [-IncludePrerelease] [-Reinstall] [-FileConflictAction]
    [-DependencyVersion] [-ToHighestPatch] [-ToHighestMinor] [-WhatIf] [<CommonParameters>]

例如:

# Updates all packages in every project of the solution
Update-Package

# Updates every package in the MvcApplication1 project
Update-Package -ProjectName MvcApplication1

# Updates the Elmah package in every project to the latest version
Update-Package Elmah

# Updates the Elmah package to version 1.1.0 in every project showing optional -Id usage
Update-Package -Id Elmah -Version 1.1.0

# Updates the Elmah package within the MvcApplication1 project to the highest "safe" version.
# For example, if Elmah version 1.0.0 of a package is installed, and versions 1.0.1, 1.0.2,
# and 1.1 are available in the feed, the -Safe parameter updates the package to 1.0.2 instead
# of 1.1 as it would otherwise.
Update-Package Elmah -ProjectName MvcApplication1 -Safe

# Reinstall the same version of the original package, but with the latest version of dependencies
# (subject to version constraints). If this command rolls a dependency back to an earlier version,
# use Update-Package <dependency_name> to reinstall that one dependency without affecting the
# dependent package.
Update-Package Elmah –reinstall

# Reinstall the Elmah package in just MyProject
Update-Package Elmah -ProjectName MyProject -reinstall

# Reinstall the same version of the original package without touching dependencies.
Update-Package Elmah –reinstall -ignoreDependencies

4. 查找包

Get-Package(Visual Studio 中的包管理器控制台)

命令:

Get-Package -Source <string> [-ListAvailable] [-Updates] [-ProjectName <string>]
    [-Filter <string>] [-First <int>] [-Skip <int>] [-AllVersions] [-IncludePrerelease]
    [-PageSize] [<CommonParameters>]

例如:

# Lists the packages installed in the current solution
# 列出当前解决方案中安装的所有包
Get-Package

# 列出安装了某个包的所有项目
Get-Package PackageName

# Lists the packages installed in a project
Get-Package -ProjectName MyProject

# Lists packages available in the current package source
Get-Package -ListAvailable

# Lists 30 packages at a time from the current source, and prompts to continue if more are available
Get-Package -ListAvailable -PageSize 30

# Lists packages with the Ninject keyword in the current source, up to 50
Get-Package -ListAvailable -Filter Ninject

# List all versions of packages matching the filter "jquery"
Get-Package -ListAvailable -Filter jquery -AllVersions

# Lists packages installed in the solution that have available updates
Get-Package -Updates

# Lists packages installed in a specific project that have available updates
Get-Package -Updates -ProjectName MyProject

5. 卸载包

Uninstall-Package(Visual Studio 中的包管理器控制台)

命令:

Uninstall-Package [-Id] <string> [-RemoveDependencies] [-ProjectName <string>] [-Force]
    [-Version <string>] [-WhatIf] [<CommonParameters>]

例如:

# Uninstalls the Elmah package from the default project
Uninstall-Package Elmah

# Uninstalls the Elmah package and all its unused dependencies
Uninstall-Package Elmah -RemoveDependencies

# Uninstalls the Elmah package even if another package depends on it
Uninstall-Package Elmah -Force

NuGet包服务器

NuGet.Server

hand-right NuGet.Server

NuGet.Server 是由 .NET Foundation 提供的包,其创建的 ASP.NET 应用程序可在运行 IIS 的任何服务器上托管包源。 简而言之,NuGet.Server 通过 HTTP(尤其是 OData)在服务器上提供文件夹。 其设置方法十分简单,最适用于简单的方案。

  1. 在 Visual Studio 中创建空的 ASP.NET Web 应用程序并向其添加 NuGet.Server 包。
  2. 配置应用程序中的 Packages 文件夹并添加包。
  3. 将应用程序部署到适合的客户端。

以下各节使用 C# 详细演练此过程。

如果对 NuGet.Server 有进一步的疑问,请在 https://github.com/nuget/NuGetGallery/issues 上创建问题。

BaGet

hand-right BaGet

https://loic-sharma.github.io/BaGet/

BaGet (pronounced "baguette") is a lightweight NuGet and symbol server. It is open source, cross-platform, and cloud ready!

常见的 NuGet 配置

NuGet 的行为受一个或多个 NuGet.Config (XML) 文件中累积设置驱动,这些文件可以存在于解决方案(如果不使用解决方案,则存在项目)、用户和计算机级别。 还可以使用全局 NuGetDefaults.Config 文件专门配置包源。 这些设置应用于 CLI、包管理器控制台和包管理器 UI 中发出的所有命令。

hand-right 常见的 NuGet 配置

nuget.config 参考

NuGet 行为由不同 NuGet.Confignuget.config 文件中的设置来控制,如常见 NuGet 配置中所述。

nuget.config 是包含顶级 <configuration> 节点的 XML 文件,而该节点包含本主题中所述的节元素。 每个部分均包含零个或多个项。 请参阅示例配置文件。 设置名称不区分大小写,并且值可以使用环境变量

hand-right nuget.config 参考

相关参考

  1. dotnet nuget
  2. PowerShell 参考
  3. 修改项目中packages包目录
  4. NuGet的使用、部署、搭建私有服务

标签:nuget,nupkg,Package,Elmah,管理,NuGet,推送
From: https://www.cnblogs.com/lanwah/p/18141665

相关文章

  • 实景三维技术在社区服务与管理领域的应用
    随着科技的不断发展,实景三维技术已经成为了社区服务与管理领域的一项重要工具。实景三维技术可以通过高精度的三维建模技术,将现实世界中的场景、物体以及人物进行数字化重建,使得人们可以在计算机中实现对现实世界的全方位、多角度的观察和分析。在社区服务与管理领域,实景三维技......
  • Linux与Shell 第2天 实操、软件包管理、Shell编程
    传送门Linux与Shell第0天阿里云安装Ubuntu22.04以及桌面Linux与Shell第1天文件目录、VIM、网络配置、系统管理、远程登录Linux与Shell第2天实操、软件包管理、Shell编程实操菜鸟教程Linux命令大全文件目录输入作用ls-a显示隐藏文件ls-lh详细信息......
  • 磁盘与文件系统管理
    磁盘与文件系统管理目录磁盘与文件系统管理一、磁盘结构及分区表示1.1、硬盘的物理结构1.2、硬盘的数据结构1.3、存储容量1.4、磁盘接口类型二、MBR与磁盘分区1、为什么分区2、MBR分区3、分区方式4、分区分类二、管理文件系统1、文件系统类型1.1XFS文件系统1.2Swap,交......
  • 08 Vue3项目搭建后台管理系统
    项目配置elementPlus1.下载安装npminstallelement-plus@element-plus/icons-vue2.main.ts全局注册import{createApp}from'vue';import{createPinia}from'pinia';//1.引入elementPlusimportElementPlusfrom'element-plus';//......
  • mysql8.0管理用户
    --使用mysql数据库USEmysql;--创建用户CREATEUSERmyuserIDENTIFIEDBY'mypass';--查看用户SELECTuser,host,authentication_stringFROMUSERWHEREUSER='myuser';--修改用户密码updateusersetauthentication_string=''whereuser='m......
  • 新连点器和bat不弹黑窗口且自动获取管理员权限
    标题好长新的连点器相比原来那个c语言版,这次使用python编写,添加了简单的图形界面,参数调整非常简单(指的是直接编辑源码)直接贴完整代码:#导入模块importtkinterastkimportthreadingimportpyautoguiimportkeyboard#定义全局变量running=False#是否开启连点int......
  • 自建一款现代化的K8s可视化管理系统
    自建一款现代化的K8s可视化管理系统原创 院长技术 院长技术 2024-03-0107:30 北京 3人听过院长简介作者:院长职位:运维开发工程师官网:https://deanit.cn博客:https://blog.deanit.cn擅长:【虚拟化,容器化,自动化运维,CICD,监控,日志,中间件,双机热备,分布式存储,数据库,认......
  • i-MES生产制造管理系统-老化时间管控
    在生产过程中,产品的可靠性是影响其性能和寿命的关键因素,因此提高产品的可靠性是十分必要的,而老化测试是提高产品可靠性的重要手段之一,老化的时间随着产品不同而变化,因此老化时间管控变得尤为重要! 在MES系统中找到“老化时间”管理的菜单,进进入之后可针对不同的产品编码设定老......
  • FreeRTOS时间管理
    FreeRTOS时间管理主要要了解延时函数:相对延时:指每次延时都是从执行函数vTaskDelay()开始,直到延时指定的时间结束。绝对延时:指将整个任务的运行周期看成一个整体,适用于需要按照一定频率运行的任务。函数vTaskDelayUntil()是绝对模式(绝对延时函数)。函数vTaskDelay()在文件......
  • 31.SpringBoot项目_员工管理系统总结 下
    本来想好好整理最后结束的奈何又接了个项目一个挺大的项目更能运用所以时间不够就简单整理算烂了个尾吧首先:1.人工AI取代程序员对我来说是不对的确实是骗外行的但其确实强大带来的便利但也只有程序员才能完美部署并运用它2.有多少人像我一样不喜欢wordexcelppt喜......