翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
CodeBuild で NuGet パッケージを使用する
次のステップは、CodeBuild に用意されている Docker イメージ に記載されているオペレーティングシステムでテストされています。
IAM ロールを使用したアクセス許可の設定
これらのステップは、CodeBuild で CodeArtifact の NuGet パッケージを使用する場合に必要です。
にサインイン AWS マネジメントコンソール し、https://console.aws.amazon.com/iam/
で IAM コンソールを開きます。 -
ナビゲーションペインで Roles (ロール) を選択します。ロールページで、CodeBuild 構築プロジェクトで使用されるロールを編集します。このロールには、以下のアクセス許可が必要です。
重要
CodeBuild を使用してパッケージを公開する場合は、
codeartifact:PublishPackageVersionアクセス許可 を追加します。詳細については、IAM ユーザーガイド の ロールの変更 を参照してください。
NuGet パッケージを消費する
CodeBuild から NuGet パッケージを消費するには、以下をプロジェクトの buildspec.yaml ファイルに含めます。
installセクションで、CodeArtifact 認証情報プロバイダーをインストールして、msbuildおよびdotnetのようなコマンドラインツールを設定します。そして、CodeArtifact にパッケージを構築して公開します。pre-buildセクションで、CodeArtifact リポジトリを NuGet 設定に追加します。
次のbuildspec.yaml 例を参照してください。詳細については、NuGetでCodeArtifactを使う を参照してください。
認証情報プロバイダーがインストールされ、リポジトリソースが追加されたら、NuGet CLI ツールコマンドを build セクションから実行して NuGet パッケージを消費できます。
Linux
dotnet を使用して NuGet パッケージを消費するには:
version: 0.2 phases: install: runtime-versions: dotnet: latest commands: - export PATH="$PATH:/root/.dotnet/tools" - dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider - dotnet codeartifact-creds install pre_build: commands: - dotnet nuget add source -n codeartifact $(aws codeartifact get-repository-endpoint --domainmy_domain--domain-owner111122223333--repositorymy_repo--format nuget --query repositoryEndpoint --output text)"v3/index.json" build: commands: - dotnet add package <packageName> --source codeartifact
Server
dotnet を使用して NuGet パッケージを消費するには:
version: 0.2 phases: install: commands: - dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider - dotnet codeartifact-creds install pre_build: commands: - dotnet nuget add source -n codeartifact "$(aws codeartifact get-repository-endpoint --domainmy_domain--domain-owner111122223333--repositorymy_repo--format nuget --query repositoryEndpoint --output text)v3/index.json" build: commands: - dotnet add package <packageName> --source codeartifact
NuGet パッケージで構築する
CodeBuild から NuGet パッケージを使用して構築するには、以下をプロジェクトの buildspec.yaml ファイルに含めます。
installセクションで、CodeArtifact 認証情報プロバイダーをインストールして、msbuildおよびdotnetのようなコマンドラインツールを設定します。そして、CodeArtifact にパッケージを構築して公開します。pre-buildセクションで、CodeArtifact リポジトリを NuGet 設定に追加します。
次のbuildspec.yaml 例を参照してください。詳細については、NuGetでCodeArtifactを使う を参照してください。
認証情報プロバイダーがインストールされ、リポジトリソースが追加されたら、build セクションから dotnet build のような NuGet CLI ツールコマンドを実行できます。
Linux
dotnet を使用して NuGet パッケージを構築するには:
version: 0.2 phases: install: runtime-versions: dotnet: latest commands: - export PATH="$PATH:/root/.dotnet/tools" - dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider - dotnet codeartifact-creds install pre_build: commands: - dotnet nuget add source -n codeartifact $(aws codeartifact get-repository-endpoint --domain my_domain --domain-owner 111122223333 --repository my_repo --format nuget --query repositoryEndpoint --output text)"v3/index.json" build: commands: - dotnet build
msbuild を使用して NuGet パッケージを構築するには:
version: 0.2 phases: install: runtime-versions: dotnet: latest commands: - export PATH="$PATH:/root/.dotnet/tools" - dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider - dotnet codeartifact-creds install pre_build: commands: - dotnet nuget add source -n codeartifact $(aws codeartifact get-repository-endpoint --domainmy_domain--domain-owner111122223333--repositorymy_repo--format nuget --query repositoryEndpoint --output text)"v3/index.json" build: commands: - msbuild -t:Rebuild -p:Configuration=Release
Server
dotnet を使用して NuGet パッケージを構築するには:
version: 0.2 phases: install: commands: - dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider - dotnet codeartifact-creds install pre_build: commands: - dotnet nuget add source -n codeartifact "$(aws codeartifact get-repository-endpoint --domainmy_domain--domain-owner111122223333--repositorymy_repo--format nuget --query repositoryEndpoint --output text)v3/index.json" build: commands: - dotnet build
msbuild を使用して NuGet パッケージを構築するには:
version: 0.2 phases: install: commands: - dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider - dotnet codeartifact-creds install pre_build: commands: - dotnet nuget add source -n codeartifact "$(aws codeartifact get-repository-endpoint --domainmy_domain--domain-owner111122223333--repositorymy_repo--format nuget --query repositoryEndpoint --output text)v3/index.json" build: commands: - msbuild -t:Rebuild -p:Configuration=Release
NuGet パッケージを公開する
CodeBuild から NuGet パッケージを公開するには、以下をプロジェクトの buildspec.yaml ファイルに含めます。
installセクションで、CodeArtifact 認証情報プロバイダーをインストールして、msbuildおよびdotnetのようなコマンドラインツールを設定します。そして、CodeArtifact にパッケージを構築して公開します。pre-buildセクションで、CodeArtifact リポジトリを NuGet 設定に追加します。
次のbuildspec.yaml 例を参照してください。詳細については、NuGetでCodeArtifactを使う を参照してください。
認証情報プロバイダーがインストールされ、リポジトリソースが追加されたら、NuGet CLI ツールコマンドを build セクションから実行して、NuGet パッケージを公開できます。
Linux
dotnet を使用して NuGet パッケージを公開するには:
version: 0.2 phases: install: runtime-versions: dotnet: latest commands: - export PATH="$PATH:/root/.dotnet/tools" - dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider - dotnet codeartifact-creds install pre_build: commands: - dotnet nuget add source -n codeartifact $(aws codeartifact get-repository-endpoint --domainmy_domain--domain-owner111122223333--repositorymy_repo--format nuget --query repositoryEndpoint --output text)"v3/index.json" build: commands: - dotnet pack -o . - dotnet nuget push *.nupkg -s codeartifact
Server
dotnet を使用して NuGet パッケージを公開するには:
version: 0.2 phases: install: commands: - dotnet tool install -g AWS.CodeArtifact.NuGet.CredentialProvider - dotnet codeartifact-creds install pre_build: commands: - dotnet nuget add source -n codeartifact "$(aws codeartifact get-repository-endpoint --domainmy_domain--domain-owner111122223333--repositorymy_repo--format nuget --query repositoryEndpoint --output text)v3/index.json" build: commands: - dotnet pack -o . - dotnet nuget push *.nupkg -s codeartifact