[Visual Studio] 於 built project 後自動建立 NuGet package

Package 是指一堆已打包的Library, 要叫用時, 則須要將整個package 透過某些 hosting (Repository) 下載並放於自己的project 中叫用, Web development中, 最常見的Repository 為 NPM, 而Java 則主要是Gradle 和Maven. 而在.net 中, 通常都會使用 NuGet.

在Visual Studio 中, 要將Package 打包, 須要安裝 NuGet CommandLine, 於Powershell 中, 指令如下:

Install-Package NuGet.CommandLine

而在Package Management Console 中, 可以透過以下方法快速生成nupkg 檔:

NuGet pack <<Project Path>>.csproj

若想在每次Project built 後都自動生成nupkg 檔, 則可以在Project Property > Build Events > Post-build event command line 中輸入以下指令:

nuget pack "$(ProjectPath)"

那每次Built 後, 都會自動生成nupkg 於project 中.

Reference

About C.H. Ling 262 Articles
a .net / Java developer from Hong Kong and currently located in United Kingdom. Thanks for Google because it solve many technical problems so I build this blog as return. Besides coding and trying advance technology, hiking and traveling is other favorite to me, so I will write down something what I see and what I feel during it. Happy reading!!!

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.