惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Jina AI
Jina AI
C
Check Point Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Threatpost
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Know Your Adversary
Know Your Adversary
C
Cyber Attacks, Cyber Crime and Cyber Security
T
Tor Project blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
Latest news
Latest news
Project Zero
Project Zero
T
Threat Research - Cisco Blogs
P
Palo Alto Networks Blog
雷峰网
雷峰网
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
N
News and Events Feed by Topic
P
Privacy International News Feed
Vercel News
Vercel News
T
The Exploit Database - CXSecurity.com
S
Secure Thoughts
Application and Cybersecurity Blog
Application and Cybersecurity Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
F
Full Disclosure
T
Tenable Blog
Last Week in AI
Last Week in AI
Y
Y Combinator Blog
SecWiki News
SecWiki News
C
CERT Recently Published Vulnerability Notes
Forbes - Security
Forbes - Security
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
S
Security Affairs
The GitHub Blog
The GitHub Blog
J
Java Code Geeks
Blog — PlanetScale
Blog — PlanetScale
N
Netflix TechBlog - Medium
O
OpenAI News
Google DeepMind News
Google DeepMind News
V
Vulnerabilities – Threatpost
Engineering at Meta
Engineering at Meta
Hacker News - Newest:
Hacker News - Newest: "LLM"
N
News and Events Feed by Topic
The Cloudflare Blog
Stack Overflow Blog
Stack Overflow Blog
Schneier on Security
Schneier on Security
W
WeLiveSecurity
Recorded Future
Recorded Future
C
CXSECURITY Database RSS Feed - CXSecurity.com
博客园 - 三生石上(FineUI控件)

博客园 - harrychinese

机器学习实战示例和基础知识查漏补缺 jupyter notebook上的java kernel 数据分析中几个常用的java类 我认为 C# 几个重要的设计缺陷 Jupyter notebook 最简安装方法 使用Tribuo分析波士顿房产数据 Java 语言常用的技巧 Java AI agent框架 java jbang 工具让java作为脚本语言 VS code + Jypyter 插件构建 Java notebook 环境 使用 VS code + Oracle java 插件搭建java语言原生的notebook环境 【计算机科学速成课】[40集全/精校] - Crash Course Computer Science Handy toolbox for IT developers 中学学校教材下载 深度学习模型训练5个关键步骤 使用SpringBoot实现一个执行通用SQL的Rest接口 学益升X1和国悦K3阅读器 状态机 使用场景规则匹配模式代替复杂的if else条件判断 vscode 数据处理的插件 iPhone XR 升级非最新版IOS duckdb ML.Net机器学习基本知识 机器学习资料汇总 优化算法知识和类库 C# XML 序列化器 画草图和示意图的好工具 .net debug tools 运筹学/最优化讲义.pdf Lazarus
nuget打包部署完整步骤
harrychinese · 2025-05-11 · via 博客园 - harrychinese

1. 类库项目文件增加打包信息

假设 package 名定义为 company.mydll

<PropertyGroup>
  <TargetFramework>net6.0</TargetFramework> <!-- 或其他目标框架 -->
  <PackageId>company.mydll</PackageId> <!-- 包的唯一标识 -->
  <Version>1.0.0</Version> <!-- 包的版本号 -->
  <Authors>Your Name</Authors> <!-- 作者名称 -->
  <Description>Your package description</Description> <!-- 包描述 -->
  <PackageLicenseExpression>MIT</PackageLicenseExpression> <!-- 许可证 -->
  <PackageTags>tag1;tag2</PackageTags> <!-- 标签 -->
  <RepositoryUrl>https://github.com/your/repo</RepositoryUrl> <!-- 源代码仓库链接 -->
  <GenerateDocumentationFile>true </GenerateDocumentationFile> <!-- 包文件中是否包含 XML 文档, 这个xml文档将包含 class/method/parameter的xml注释, 包含这个XML文档对于类库的使用方非常重要, IDE可以为为使用方提供增加更多的帮助信息 -->
</PropertyGroup>

2. 类库项目进行打包

下面命令会生成 nupkg 文件

# cd 到项目根目录

# pack 命令的 include-symbols 参数, 可以包含 pdb 文件, 便于调试
dotnet pack --Configuration Release --include-symbols

3. 准备一个本地nuget 私服地址

我们可以使用 BaGet 或 NuGet.Server 或 Nexus 等软件搭建本地的nuget 私服, 甚至可以使用本机或共享目录作为私服, 比如 c:\local_nuget

4. 将 nuget pkg 文件推送到私服

dotnet nuget push company.mydll.1.0.0.nupkg --source http://localhost:5000/nuget

# 如果是本地目录, 可以使用类似上面的命令, 或直接将nupkg文件复制过去即可. 

5. 为本机准备一个最简的 nuget.config 文件.

本机配置文件全路径是: C:\Users{username}\AppData\Roaming\NuGet\NuGet.Config
当然, 我们也可以在项目根目录下加一个 NuGet.Config 文件, 这样该项目将优先使用项目下的 NuGet.Config.

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
  </packageSources>  

<config> 
    <!-- 通过 globalPackagesFolder 设定, 下载的 nupkg 文件存放路径 -->
    <add key="globalPackagesFolder" value="D:\nuget\packages" />
</config>
</configuration>

6. 将本地nuget私服加到 nuget.config 文件.

可以直接编辑该文件, 或者使用下面命令为 nuget.config 中新增 nuget源.

nuget sources add -Name local_nuget -Source c:\local_nuget

最终 nuget.config 文件内容如下:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <packageSources>
    <add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
    <add key="local_nuget" value="c:\local_nuget" />
  </packageSources>
  

<config> 
    <add key="globalPackagesFolder" value="D:\nuget\packages" />
</config>
</configuration>

7. 新项目引用 company.mydll 类库

 # cd 到项目根目录
 
 # 先搜索一下目标类库的具体名称
 dotnet package search company.mydll

 # 引用目标类库 
 dotnet add package ompany.mydll