NuGetCommand@2 - NuGet v2 작업

이 작업을 사용하여 NuGet 패키지를 복원, 압축 또는 푸시하거나 NuGet 명령을 실행합니다. 이 작업은 Azure Artifacts 및 MyGet과 같은 NuGet.org 및 인증된 피드를 지원합니다. 이 작업은 NuGet.exe 사용하고 .NET Framework 앱에서도 작동합니다. .NET Core 및 .NET Standard 앱의 경우 .NET Core 작업을 사용합니다.

Syntax

# NuGet v2
# Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Azure Artifacts and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
- task: NuGetCommand@2
  inputs:
    command: 'restore' # 'restore' | 'pack' | 'push' | 'custom'. Required. Command. Default: restore.
    restoreSolution: '**/*.sln' # string. Alias: solution. Required when command = restore. Path to solution, packages.config, or project.json. Default: **/*.sln.
    #packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' # string. Alias: searchPatternPush. Required when command = push. Path to NuGet package(s) to publish. Default: $(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg.
    #nuGetFeedType: 'internal' # 'internal' | 'external'. Required when command = push. Target feed location. Default: internal.
    #publishVstsFeed: # string. Alias: feedPublish. Required when command = push && nuGetFeedType = internal. Target feed. 
    #allowPackageConflicts: false # boolean. Optional. Use when command = push && nuGetFeedType = internal. Allow duplicates to be skipped. Default: false.
    #publishFeedCredentials: # string. Alias: externalEndpoint. Required when command = push && nuGetFeedType = external. NuGet server. 
    #packagesToPack: '**/*.csproj' # string. Alias: searchPatternPack. Required when command = pack. Path to csproj or nuspec file(s) to pack. Default: **/*.csproj.
    #configuration: '$(BuildConfiguration)' # string. Alias: configurationToPack. Optional. Use when command = pack. Configuration to package. Default: $(BuildConfiguration).
    #packDestination: '$(Build.ArtifactStagingDirectory)' # string. Alias: outputDir. Optional. Use when command = pack. Package folder. Default: $(Build.ArtifactStagingDirectory).
    #arguments: # string. Required when command = custom. Command and arguments. 
  # Feeds and authentication
    feedsToUse: 'select' # 'select' | 'config'. Alias: selectOrConfig. Required when command = restore. Feeds to use. Default: select.
    #vstsFeed: # string. Alias: feedRestore. Optional. Use when selectOrConfig = select && command = restore. Use packages from this Azure Artifacts/TFS feed. 
    #includeNuGetOrg: true # boolean. Optional. Use when selectOrConfig = select && command = restore. Use packages from NuGet.org. Default: true.
    #nugetConfigPath: # string. Optional. Use when selectOrConfig = config && command = restore. Path to NuGet.config. 
    #externalFeedCredentials: # string. Alias: externalEndpoints. Optional. Use when selectOrConfig = config && command = restore. Credentials for feeds outside this organization/collection. 
  # Advanced
    #noCache: false # boolean. Optional. Use when command = restore. Disable local cache. Default: false.
    #disableParallelProcessing: false # boolean. Optional. Use when command = restore. Disable parallel processing. Default: false.
    #restoreDirectory: # string. Alias: packagesDirectory. Optional. Use when command = restore. Destination directory. 
    #verbosityRestore: 'Detailed' # 'Quiet' | 'Normal' | 'Detailed'. Optional. Use when command = restore. Verbosity. Default: Detailed.
  # Advanced
    #publishPackageMetadata: true # boolean. Optional. Use when command = push && nuGetFeedType = internal && command = push. Publish pipeline metadata. Default: true.
    #verbosityPush: 'Detailed' # 'Quiet' | 'Normal' | 'Detailed'. Optional. Use when command = push. Verbosity. Default: Detailed.
  # Pack options
    #versioningScheme: 'off' # 'off' | 'byPrereleaseNumber' | 'byEnvVar' | 'byBuildNumber'. Required when command = pack. Automatic package versioning. Default: off.
    #includeReferencedProjects: false # boolean. Optional. Use when versioningScheme = off && command = pack. Include referenced projects. Default: false.
    #versionEnvVar: # string. Required when versioningScheme = byEnvVar && command = pack. Environment variable. 
    #majorVersion: '1' # string. Alias: requestedMajorVersion. Required when versioningScheme = byPrereleaseNumber && command = pack. Major. Default: 1.
    #minorVersion: '0' # string. Alias: requestedMinorVersion. Required when versioningScheme = byPrereleaseNumber && command = pack. Minor. Default: 0.
    #patchVersion: '0' # string. Alias: requestedPatchVersion. Required when versioningScheme = byPrereleaseNumber && command = pack. Patch. Default: 0.
    #packTimezone: 'utc' # 'utc' | 'local'. Optional. Use when versioningScheme = byPrereleaseNumber && command = pack. Time zone. Default: utc.
    #includeSymbols: false # boolean. Optional. Use when command = pack. Create symbols package. Default: false.
    #toolPackage: false # boolean. Optional. Use when command = pack. Tool Package. Default: false.
  # Advanced
    #buildProperties: # string. Optional. Use when command = pack. Additional build properties. 
    #basePath: # string. Optional. Use when command = pack. Base path. 
    #verbosityPack: 'Detailed' # 'Quiet' | 'Normal' | 'Detailed'. Optional. Use when command = pack. Verbosity. Default: Detailed.
# NuGet v2
# Restore, pack, or push NuGet packages, or run a NuGet command. Supports NuGet.org and authenticated feeds like Package Management and MyGet. Uses NuGet.exe and works with .NET Framework apps. For .NET Core and .NET Standard apps, use the .NET Core task.
- task: NuGetCommand@2
  inputs:
    command: 'restore' # 'restore' | 'pack' | 'push' | 'custom'. Required. Command. Default: restore.
    restoreSolution: '**/*.sln' # string. Alias: solution. Required when command = restore. Path to solution, packages.config, or project.json. Default: **/*.sln.
    #packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg' # string. Alias: searchPatternPush. Required when command = push. Path to NuGet package(s) to publish. Default: $(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg.
    #nuGetFeedType: 'internal' # 'internal' | 'external'. Required when command = push. Target feed location. Default: internal.
    #publishVstsFeed: # string. Alias: feedPublish. Required when command = push && nuGetFeedType = internal. Target feed. 
    #allowPackageConflicts: false # boolean. Optional. Use when command = push && nuGetFeedType = internal. Allow duplicates to be skipped. Default: false.
    #publishFeedCredentials: # string. Alias: externalEndpoint. Required when command = push && nuGetFeedType = external. NuGet server. 
    #packagesToPack: '**/*.csproj' # string. Alias: searchPatternPack. Required when command = pack. Path to csproj or nuspec file(s) to pack. Default: **/*.csproj.
    #configuration: '$(BuildConfiguration)' # string. Alias: configurationToPack. Optional. Use when command = pack. Configuration to package. Default: $(BuildConfiguration).
    #packDestination: '$(Build.ArtifactStagingDirectory)' # string. Alias: outputDir. Optional. Use when command = pack. Package folder. Default: $(Build.ArtifactStagingDirectory).
    #arguments: # string. Required when command = custom. Command and arguments. 
  # Feeds and authentication
    feedsToUse: 'select' # 'select' | 'config'. Alias: selectOrConfig. Required when command = restore. Feeds to use. Default: select.
    #vstsFeed: # string. Alias: feedRestore. Optional. Use when selectOrConfig = select && command = restore. Use packages from this Azure Artifacts/TFS feed. 
    #includeNuGetOrg: true # boolean. Optional. Use when selectOrConfig = select && command = restore. Use packages from NuGet.org. Default: true.
    #nugetConfigPath: # string. Optional. Use when selectOrConfig = config && command = restore. Path to NuGet.config. 
    #externalFeedCredentials: # string. Alias: externalEndpoints. Optional. Use when selectOrConfig = config && command = restore. Credentials for feeds outside this account/collection. 
  # Advanced
    #noCache: false # boolean. Optional. Use when command = restore. Disable local cache. Default: false.
    #disableParallelProcessing: false # boolean. Optional. Use when command = restore. Disable parallel processing. Default: false.
    #restoreDirectory: # string. Alias: packagesDirectory. Optional. Use when command = restore. Destination directory. 
    #verbosityRestore: 'Detailed' # 'Quiet' | 'Normal' | 'Detailed'. Optional. Use when command = restore. Verbosity. Default: Detailed.
  # Advanced
    #verbosityPush: 'Detailed' # 'Quiet' | 'Normal' | 'Detailed'. Optional. Use when command = push. Verbosity. Default: Detailed.
  # Pack options
    #versioningScheme: 'off' # 'off' | 'byPrereleaseNumber' | 'byEnvVar' | 'byBuildNumber'. Required when command = pack. Automatic package versioning. Default: off.
    #includeReferencedProjects: false # boolean. Optional. Use when versioningScheme = off && command = pack. Include referenced projects. Default: false.
    #versionEnvVar: # string. Required when versioningScheme = byEnvVar && command = pack. Environment variable. 
    #majorVersion: '1' # string. Alias: requestedMajorVersion. Required when versioningScheme = byPrereleaseNumber && command = pack. Major. Default: 1.
    #minorVersion: '0' # string. Alias: requestedMinorVersion. Required when versioningScheme = byPrereleaseNumber && command = pack. Minor. Default: 0.
    #patchVersion: '0' # string. Alias: requestedPatchVersion. Required when versioningScheme = byPrereleaseNumber && command = pack. Patch. Default: 0.
    #packTimezone: 'utc' # 'utc' | 'local'. Optional. Use when versioningScheme = byPrereleaseNumber && command = pack. Time zone. Default: utc.
    #includeSymbols: false # boolean. Optional. Use when command = pack. Create symbols package. Default: false.
    #toolPackage: false # boolean. Optional. Use when command = pack. Tool Package. Default: false.
  # Advanced
    #buildProperties: # string. Optional. Use when command = pack. Additional build properties. 
    #basePath: # string. Optional. Use when command = pack. Base path. 
    #verbosityPack: 'Detailed' # 'Quiet' | 'Normal' | 'Detailed'. Optional. Use when command = pack. Verbosity. Default: Detailed.

입력

command - 명령
string. 필수 요소. 허용되는 값: restore, pack, push, . custom 기본값은 restore입니다.

실행할 NuGet 명령을 지정합니다. custom 값을 사용하여 인수를 추가하거나 다른 명령을 사용합니다.


restoreSolution - 솔루션, packages.config 또는 project.json 경로
입력 별칭: solution. string. 필요한 경우 command = restore입니다. 기본값은 **/*.sln입니다.

복원할 패키지를 참조하는 솔루션 또는 packages.configproject.json 파일의 경로를 지정합니다.


feedsToUse - 사용할 피드
입력 별칭: selectOrConfig. string. 필요한 경우 command = restore입니다. 허용되는 값: select (여기서 선택한 피드), config (NuGet.config 피드). 기본값은 select입니다.

값과 함께 사용할 작업에 대한 Azure Artifacts 및/또는 NuGet.org 피드를 select 지정합니다. 또는 소스 코드 리포지토리에 파일을 커밋 NuGet.config 하고 값을 사용하여 config 해당 경로를 값으로 설정할 수 있습니다.


vstsFeed - 이 Azure Artifacts/TFS 피드의 패키지 사용
입력 별칭: feedRestore. string. 선택 사항입니다. 를 사용하는 경우 selectOrConfig = select && command = restore를 사용합니다.

생성된 NuGet.config에서 선택한 피드를 지정합니다. 여기에 피드를 지정하려면 패키지 관리가 설치되고 라이선스가 있어야 합니다.


includeNuGetOrg - NuGet.org 패키지 사용
boolean. 선택 사항입니다. 를 사용하는 경우 selectOrConfig = select && command = restore를 사용합니다. 기본값은 true입니다.

생성된 NuGet.config의 NuGet.org 포함합니다.


nugetConfigPath - NuGet.config경로
string. 선택 사항입니다. 를 사용하는 경우 selectOrConfig = config && command = restore를 사용합니다.

패키지를 복원할 피드를 NuGet.config 결정하는 리포지토리의 에 대한 경로를 지정합니다.


externalFeedCredentials - 이 organization/컬렉션 외부의 피드에 대한 자격 증명
입력 별칭: externalEndpoints. string. 선택 사항입니다. 를 사용하는 경우 selectOrConfig = config && command = restore를 사용합니다.

선택한 에 있는 외부 레지스트리에 사용할 자격 증명을 NuGet.config지정합니다. NuGet 서비스 연결의 이름입니다. 이 organization 또는 컬렉션의 피드의 경우 이 값을 비워 둡니다. 빌드의 자격 증명이 자동으로 사용됩니다.


externalFeedCredentials - 이 계정/컬렉션 외부의 피드에 대한 자격 증명
입력 별칭: externalEndpoints. string. 선택 사항입니다. 를 사용하는 경우 selectOrConfig = config && command = restore를 사용합니다.

선택한 에 있는 외부 레지스트리에 사용할 자격 증명을 NuGet.config지정합니다. NuGet 서비스 연결의 이름입니다. 이 계정 또는 컬렉션의 피드의 경우 이 항목을 비워 둡니다. 빌드의 자격 증명이 자동으로 사용됩니다.


noCache - 로컬 캐시 사용 안 함
boolean. 선택 사항입니다. 를 사용하는 경우 command = restore를 사용합니다. 기본값은 false입니다.

으로 설정 true하면 NuGet이 로컬 컴퓨터 캐시의 패키지를 사용하지 못하도록 방지합니다.


disableParallelProcessing - 병렬 처리 사용 안 함
boolean. 선택 사항입니다. 를 사용하는 경우 command = restore를 사용합니다. 기본값은 false입니다.

으로 설정하면 NuGet이 병렬 프로세스에 여러 패키지를 설치하지 못하도록 방지합니다 true.


restoreDirectory - 대상 디렉터리
입력 별칭: packagesDirectory. string. 선택 사항입니다. 를 사용하는 경우 command = restore를 사용합니다.

패키지가 설치되는 폴더를 지정합니다. 폴더를 지정하지 않으면 패키지가 선택한 솔루션, packages.config또는 project.json와 함께 폴더로 packages/ 복원됩니다.


verbosityRestore - 세부 정보 표시
string. 선택 사항입니다. 를 사용하는 경우 command = restore를 사용합니다. 허용되는 값: Quiet, Normal, Detailed. 기본값은 Detailed입니다.

출력에 표시되는 세부 정보의 양을 지정합니다.


packagesToPush - 게시할 NuGet 패키지 경로
입력 별칭: searchPatternPush. string. 필요한 경우 command = push입니다. 기본값은 $(Build.ArtifactStagingDirectory)/**/*.nupkg;!$(Build.ArtifactStagingDirectory)/**/*.symbols.nupkg입니다.

일치시킬 패턴 또는 업로드할 파일의 nupkg 경로를 지정합니다. 여러 패턴을 세미콜론으로 구분할 수 있습니다.


nuGetFeedType - 대상 피드 위치
string. 필요한 경우 command = push입니다. 허용되는 값: internal (이 organization/컬렉션), external (외부 NuGet 서버(다른 계정/컬렉션 포함)) 기본값은 internal입니다.

대상 피드가 내부 피드/컬렉션인지 아니면 외부 NuGet 서버인지를 지정합니다.


nuGetFeedType - 대상 피드 위치
string. 필요한 경우 command = push입니다. 허용되는 값: internal (이 계정/컬렉션), external (외부 NuGet 서버(다른 계정/컬렉션 포함)) 기본값은 internal입니다.

대상 피드가 내부 피드/컬렉션인지 아니면 외부 NuGet 서버인지를 지정합니다.


publishVstsFeed - 대상 피드
입력 별칭: feedPublish. string. 필요한 경우 command = push && nuGetFeedType = internal입니다.

이 계정에서 호스트되는 피드를 지정합니다. 여기서 피드를 선택하려면 Azure Artifacts가 설치되고 라이선스가 있어야 합니다.


publishPackageMetadata - 파이프라인 메타데이터 게시
boolean. 선택 사항입니다. 를 사용하는 경우 command = push && nuGetFeedType = internal && command = push를 사용합니다. 기본값은 true입니다.

지속적으로 게시된 패키지 집합 내에서 변경된 패키지 하위 집합의 버전 번호를 변경합니다.


allowPackageConflicts - 중복 항목 건너뛰기 허용
boolean. 선택 사항입니다. 를 사용하는 경우 command = push && nuGetFeedType = internal를 사용합니다. 기본값은 false입니다.

일부 패키지가 409 충돌 오류로 거부되더라도 작업 성공을 보고합니다.

이 옵션은 현재 Azure Pipelines 및 Windows 에이전트에서만 사용할 수 있습니다. NuGet.exe 충돌이 발생하면 작업이 실패합니다. 이 옵션은 작동하지 않으며 프록시 환경 내에 있는 경우 게시가 실패합니다.


publishFeedCredentials - NuGet 서버
입력 별칭: externalEndpoint. string. 필요한 경우 command = push && nuGetFeedType = external입니다.

외부 NuGet 서버의 자격 증명을 포함하는 NuGet 서비스 연결을 지정합니다.


verbosityPush - 세부 정보 표시
string. 선택 사항입니다. 를 사용하는 경우 command = push를 사용합니다. 허용되는 값: Quiet, Normal, Detailed. 기본값은 Detailed입니다.

출력에 표시되는 세부 정보의 양을 지정합니다.


packagesToPack - 압축할 csproj 또는 nuspec 파일 경로
입력 별칭: searchPatternPack. string. 필요한 경우 command = pack입니다. 기본값은 **/*.csproj입니다.

태스크가 압축할 csproj 디렉터리를 검색하는 데 사용하는 패턴을 지정합니다.

여러 패턴을 세미콜론으로 구분할 수 있으며, 접두사를 사용하여 패턴을 음수로 !만들 수 있습니다. 예: **\*.csproj;!**\*.Tests.csproj.


configuration - 패키지에 대한 구성
입력 별칭: configurationToPack. string. 선택 사항입니다. 를 사용하는 경우 command = pack를 사용합니다. 기본값은 $(BuildConfiguration)입니다.

csproj 파일을 사용할 때 패키지할 구성을 지정합니다.


packDestination - 패키지 폴더
입력 별칭: outputDir. string. 선택 사항입니다. 를 사용하는 경우 command = pack를 사용합니다. 기본값은 $(Build.ArtifactStagingDirectory)입니다.

태스크에서 패키지를 만드는 폴더를 지정합니다. 값이 비어 있으면 작업은 원본 루트에 패키지를 만듭니다.


versioningScheme - 자동 패키지 버전 관리
string. 필요한 경우 command = pack입니다. 허용되는 값: off, byPrereleaseNumber (날짜 및 시간 사용), byEnvVar (환경 변수 사용), byBuildNumber (빌드 번호 사용). 기본값은 off입니다.

지정된 값에 따라 자동 패키지 버전 관리를 적용합니다. 이 문자열은 와 함께 includeReferencedProjects사용할 수 없습니다. 허용되는 값은 다음과 같습니다.

  • byPrereleaseNumber - 날짜 및 시간 사용: 작업은 X, Y 및 Z 값을 지정하는 형식X.Y.Z-ci-datetimeSemVer 규격 버전을 생성합니다.
  • byEnvVar- 환경 변수 사용: 태스크는 지정한 환경 변수를 사용하고 사용하려는 버전 번호를 포함합니다.
  • byBuildNumber - 빌드 번호 사용: 태스크는 빌드 번호를 사용하여 패키지의 버전을 지정합니다.

참고

일반에서 빌드 형식을 로 $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)설정합니다.


includeReferencedProjects - 참조된 프로젝트 포함
boolean. 선택 사항입니다. 를 사용하는 경우 versioningScheme = off && command = pack를 사용합니다. 기본값은 false입니다.

참조된 프로젝트를 종속성 또는 패키지의 일부로 포함합니다. 자동 패키지 버전 관리와 함께 사용할 수 없습니다. 참조된 프로젝트에 프로젝트와 이름이 같은 해당 nuspec 파일이 있는 경우 참조된 프로젝트가 종속성으로 추가됩니다. 그렇지 않으면 참조된 프로젝트가 패키지의 일부로 추가됩니다. NuGet CLI용 pack 명령을 사용하여 NuGet 패키지를 만드는 방법에 대해 자세히 알아봅니다.


versionEnvVar - 환경 변수
string. 필요한 경우 versioningScheme = byEnvVar && command = pack입니다.

, $env또는 %가 없는 $변수 이름을 지정합니다.


majorVersion - 주요
입력 별칭: requestedMajorVersion. string. 필요한 경우 versioningScheme = byPrereleaseNumber && command = pack입니다. 기본값은 1입니다.

X 버전 X.Y.Z의 입니다.


minorVersion - 사소한
입력 별칭: requestedMinorVersion. string. 필요한 경우 versioningScheme = byPrereleaseNumber && command = pack입니다. 기본값은 0입니다.

Y 버전 X.Y.Z의 입니다.


patchVersion - 패치
입력 별칭: requestedPatchVersion. string. 필요한 경우 versioningScheme = byPrereleaseNumber && command = pack입니다. 기본값은 0입니다.

Z 버전 X.Y.Z의 입니다.


packTimezone - 시간대
string. 선택 사항입니다. 를 사용하는 경우 versioningScheme = byPrereleaseNumber && command = pack를 사용합니다. 허용되는 값: utc, local (에이전트 현지 시간). 기본값은 utc입니다.

패키지 버전을 생성하는 데 사용되는 원하는 표준 시간대를 지정합니다. 호스트된 빌드 에이전트를 utc 사용하는 경우 날짜와 시간이 다를 수 있으므로 선택하는 것이 좋습니다.


includeSymbols - 기호 패키지 만들기
boolean. 선택 사항입니다. 를 사용하는 경우 command = pack를 사용합니다. 기본값은 false입니다.

패키지에 원본 및 기호가 포함되도록 지정합니다. 파일과 함께 .nuspec 사용하면 일반 NuGet 패키지 파일과 해당 기호 패키지가 만들어집니다.


toolPackage - 도구 패키지
boolean. 선택 사항입니다. 를 사용하는 경우 command = pack를 사용합니다. 기본값은 false입니다.

프로젝트의 출력 파일이 도구 폴더에 있어야 하는지 여부를 결정합니다.


buildProperties - 추가 빌드 속성
string. 선택 사항입니다. 를 사용하는 경우 command = pack를 사용합니다.

세미콜론으로 구분된 token=value 쌍 목록을 지정합니다. 여기서 파일의 $token$.nuspec 각 항목은 지정된 값으로 바뀝니다. 값은 따옴표로 된 문자열일 수 있습니다.


basePath - 기본 경로
string. 선택 사항입니다. 를 사용하는 경우 command = pack를 사용합니다.

파일에 정의된 파일의 기본 경로를 지정합니다 nuspec .


verbosityPack - 세부 정보 표시
string. 선택 사항입니다. 를 사용하는 경우 command = pack를 사용합니다. 허용되는 값: Quiet, Normal, Detailed. 기본값은 Detailed입니다.

출력에 표시되는 세부 정보의 양을 지정합니다.


arguments - 명령 및 인수
string. 필요한 경우 command = custom입니다.

실행을 위해 전달될 명령 및 인수를 NuGet.exe 지정합니다. NuGet 3.5 이상을 사용하는 경우 Project Collection Build Service에서 액세스할 수 있는 이 organization 또는 컬렉션의 모든 피드에 대해 , restorepublish 과 같은 list인증된 명령이 자동으로 인증됩니다.


작업 제어 옵션

모든 작업에는 작업 입력 외에 제어 옵션이 있습니다. 자세한 내용은 컨트롤 옵션 및 일반적인 작업 속성을 참조하세요.

출력 변수

없음

설명

중요

NuGet 인증 작업은 Azure Artifacts 및 기타 NuGet 리포지토리를 사용하여 인증하는 새로운 권장 방법입니다. 이 작업은 더 이상 새 기능을 사용하지 않으며 중요한 버그만 해결됩니다.

이 작업을 사용하여 NuGet 패키지 종속성을 설치 및 업데이트하거나 NuGet 패키지를 패키지하고 게시합니다. NuGet.exe를 사용하며 .NET Framework 앱에서 작동합니다. .NET Core 및 .NET Standard 앱의 경우 .NET Core 작업을 사용합니다.

코드가 NuGet 패키지에 의존하는 경우 Visual Studio 빌드 작업 전에 이 단계를 추가해야 합니다. 또한 해당 작업에서 사용되지 않는 NuGet 패키지 복원 확인란의 선택을 취소해야 합니다.

.NET Core 또는 .NET Standard를 사용하는 경우 모든 패키지 시나리오를 완전히 지원하고 현재 dotnet에서 지원되는 .NET Core 작업을 사용합니다.

이 버전의 NuGet 작업은 기본적으로 NuGet 4.1.0을 사용합니다. 다른 버전의 NuGet을 선택하려면 도구 설치 관리자를 사용합니다.

버전 관리 체계

byPrereleaseNumber의 경우 버전은 주 버전, 부 버전 및 패치에 대해 선택한 값과 날짜 및 시간 형식yyyymmdd-hhmmss으로 설정됩니다.

byEnvVar의 경우 버전은 versionEnvVar 매개 변수로 지정된 이름이 있는 환경 변수의 값으로 설정됩니다(예: MyVersion 아니요 $, 환경 변수 이름만 해당). 환경 변수가 또는 1.2.3-beta1와 같은 적절한 SemVer로 1.2.3 설정되어 있는지 확인합니다.

byBuildNumber의 경우 파이프라인 실행의 빌드 번호를 사용하여 버전이 설정됩니다. 이 값은 환경 변수에 저장되는 파이프라인의 속성에 BUILD_BUILDNUMBER 대해 지정된 값입니다name. 사용 중인 빌드 번호에 와 같은 1.0.$(Rev:r)적절한 SemVer가 포함되어 있는지 확인합니다. byBuildNumber를 사용하는 경우 작업은 빌드 번호 문자열에서 점선 버전 를 1.2.3.4추출하고 해당 부분만 사용합니다. 나머지 문자열은 삭제됩니다. 빌드 번호를 있는 그대로 사용하려는 경우 위에서 설명 한 대로 byEnvVar 을 사용하고 versionEnvVarBUILD_BUILDNUMBER로 설정할 수 있습니다.

NuGetInstaller@0 또는 NuGetRestore@1 마이그레이션

NuGetInstaller@0NuGetRestore@1 는 더 이상 사용되지 않으며 파이프라인에서 으로 NuGetCommand@2대체해야 합니다.

와 함께 restoreMode: restore를 사용하는 경우 를 사용할 NuGetInstaller@0NuGetCommand@2때 다음 입력을 구성합니다.

NuGetCommand@2 작업 입력
command restore
restoreSolution .sln 파일 경로

와 함께 restoreMode: install를 사용하는 경우 를 사용할 NuGetInstaller@0NuGetCommand@2때 다음 입력을 구성합니다.

NuGetCommand@2 작업 입력
command custom
arguments NuGet CLI에서 전체 설치 명령의 모양입니다. 예를 들어 파이프라인에서 에 해당하는 를 nuget install ninject -OutputDirectory c:\proj 실행하려는 경우 매개 변수는 arguments 입니다 install ninject -OutputDirectory c:\proj. 매개 변수를 NuGetInstaller@0nuGetRestoreArgs 사용하는 경우 이제 로 arguments이동합니다.

를 사용하는 NuGetRestore@1경우 를 사용할 NuGetCommand@2때 다음 입력을 구성합니다.

NuGetCommand@2 작업 입력
command restore
restoreSolution .sln 파일 경로

사용 NuGetRestore@1 또는 NuGetInstaller@0restore 옵션과 마찬가지로, NuGetCommand@2 피드를 설정하고, 또는 중 select 에서 config결정하고, 파일 경로를 NuGet.config 지정하고, nuget.org 패키지를 사용하는 입력이 있습니다.

자세한 내용은 다음 예제를 참조하세요.

예제

복원

선택한 피드에서 패키지를 사용하여 모든 솔루션을 복원합니다.

# Restore from a project scoped feed in the same organization
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    feedsToUse: 'select'
    vstsFeed: 'my-project/my-project-scoped-feed'
    includeNuGetOrg: false
    restoreSolution: '**/*.sln'
# Restore from an organization scoped feed in the same organization
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    feedsToUse: 'select'
    vstsFeed: 'my-organization-scoped-feed'
    restoreSolution: '**/*.sln'
# Restore from a feed in a different organization
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    feedsToUse: config
    nugetConfigPath: ./nuget.config
    restoreSolution: '**/*.sln'
    externalFeedCredentials: 'MyServiceConnectionName'
    noCache: true
  continueOnError: true
# Restore from feed(s) set in nuget.config
- task: NuGetCommand@2
  inputs:
    command: 'restore'
    feedsToUse: 'config'
    nugetConfigPath: 'nuget.config'

패키지

대상 폴더에 NuGet 패키지를 만듭니다.

# Package a project
- task: NuGetCommand@2
  inputs:
    command: 'pack'
    packagesToPack: '**/*.csproj'
    packDestination: '$(Build.ArtifactStagingDirectory)'

밀어넣기

참고

파이프라인 아티팩트가 디렉터리 및 클래식 릴리스 파이프라인용 System.ArtifactsDirectory 디렉터리에 다운로드 Pipeline.Workspace 됩니다. packagesToPush값은 각각 또는 $(System.ArtifactsDirectory)/**/*.nupkg$(Pipeline.Workspace)/**/*.nupkg 설정할 수 있습니다.

  • NuGet.config 정의된 피드에 패키지를 푸시/게시합니다.

    # Push a project
    - task: NuGetCommand@2
      inputs:
        command: 'push'
        packagesToPush: '$(Build.ArtifactStagingDirectory)/**/*.nupkg'
        feedsToUse: 'config'
        nugetConfigPath: '$(Build.WorkingDirectory)/NuGet.config'
    
  • organization 범위가 지정된 피드에 패키지 푸시/게시

    # Push a project
    - task: NuGetCommand@2
      inputs:
        command: 'push'
        nuGetFeedType: 'internal'
        publishVstsFeed: 'my-organization-scoped-feed'
    
  • 프로젝트 범위 피드에 패키지 푸시/게시

    # Push a project
    - task: NuGetCommand@2
      inputs:
        command: 'push'
        nuGetFeedType: 'internal'
        publishVstsFeed: 'my-project/my-project-scoped-feed'
    
  • NuGet.org 패키지 푸시/게시

    # Push a project
    - task: NuGetCommand@2
      inputs:
        command: 'push'
        feedsToUse: 'config'
        includeNugetOrg: 'true'
    

사용자 지정

팩, 푸시 및 복원과 같은 기본 명령 외에 다른 NuGet 명령을 실행합니다.

# list local NuGet resources.
- task: NuGetCommand@2
  displayName: 'list locals'
  inputs:
    command: custom
    arguments: 'locals all -list'

요구 사항

요구 사항 Description
파이프라인 유형 YAML, 클래식 빌드, 클래식 릴리스
실행 중 에이전트, DeploymentGroup
요청 없음
Capabilities 이 작업은 작업의 후속 작업에 대한 요구를 충족하지 않습니다.
명령 제한 사항 모두
Settable 변수 모두
에이전트 버전 2.144.0 이상
작업 범주 패키지
요구 사항 Description
파이프라인 유형 YAML, 클래식 빌드, 클래식 릴리스
실행 중 에이전트, DeploymentGroup
요청 없음
Capabilities 이 작업은 작업의 후속 작업에 대한 요구를 충족하지 않습니다.
명령 제한 사항 모두
설정 가능한 변수 모두
에이전트 버전 2.115.0 이상
작업 범주 패키지