# Azure Artifacts ## Best-practice [Doc](https://learn.microsoft.com/zh-tw/azure/devops/artifacts/concepts/best-practices?view=azure-devops) ## Prerequisites - Install the [latest NuGet version](https://www.nuget.org/downloads). - Install [Azure Artifacts Credential Provider](https://github.com/microsoft/artifacts-credprovider#azure-artifacts-credential-provider).(用來在跟Azure取得PAT) ## Feed 用來提供package的來源 ### 在要使用自訂Feed的專案設定 需在與`.csproj`或`.sln`同一層建立`nuget.config` - nuget.config ``` xml <?xml version="1.0" encoding="utf-8"?> <configuration> <packageSources> <clear /> <add key="Pillar" value="https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json" /> </packageSources> </configuration> ``` - Add package 第一次使用需加上`--interactive`來登入Azure ``` dotnet add package {package} ``` ### 打包Package並推送到Azure Feed - 打包Package 只會寫CI/CD的部份,使用Compiler的話按個按鈕就Build出來了 - 推送到Azure Feed 第一次使用需加上`--interactive`來登入Azure ``` dotnet nuget push --source https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json --api-key az <package-path> ``` - 範例 ``` dotnet nuget push --source https://pkgs.dev.azure.com/<ORGANIZATION_NAME>/<PROJECT_NAME>/_packaging/<FEED_NAME>/nuget/v3/index.json az ./CommonLib/bin/Debug/CommonLib.2.0.0.nupkg ``` `--api-key` 隨意,但是要有值,因為前面有登入所以不需要 `package-path` Build出來Package的位置
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up