DotNetCoreCLI@2 - .NET Core v2 タスク

DotNet アプリケーションをビルド、テスト、パッケージ化、公開するか、DotNet コマンドを実行します。

DotNet アプリケーションをビルド、テスト、パッケージ化、公開するか、DotNet コマンドを実行します。 パッケージ コマンドでは、Package Management や MyGet などの NuGet.org と認証済みフィードがサポートされます。

重要

[NuGet 認証] タスクは、Azure Artifacts などの NuGet リポジトリで認証するための新しい推奨される方法です。 この .NET Core CLI タスクの コマンドと push コマンドはrestore新機能を使用しなくなり、重大なバグのみが対処されます。 詳細については、「解説」を参照してください。

構文

# .NET Core v2
# Build, test, package, or publish a dotnet application, or run a custom dotnet command.
- task: DotNetCoreCLI@2
  inputs:
    command: 'build' # 'build' | 'push' | 'pack' | 'publish' | 'restore' | 'run' | 'test' | 'custom'. Required. Command. Default: build.
    #publishWebProjects: true # boolean. Optional. Use when command = publish. Publish web projects. Default: true.
    #projects: # string. Optional. Use when command = build || command = restore || command = run || command = test || command = custom || publishWebProjects = false. Path to project(s) or solution(s). 
    #custom: # string. Required when command = custom. Custom command. 
    #arguments: # string. Optional. Use when command = build || command = publish || command = run || command = test || command = custom. Arguments. 
    #restoreArguments: # string. Optional. Use when command = restore. Arguments. 
    #publishTestResults: true # boolean. Optional. Use when command = test. Publish test results and code coverage. Default: true.
    #testRunTitle: # string. Optional. Use when command = test. Test run title. 
    #zipAfterPublish: true # boolean. Optional. Use when command = publish. Zip published projects. Default: true.
    #modifyOutputPath: true # boolean. Optional. Use when command = publish. Add project's folder name to publish path. Default: true.
    #packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg' # string. Alias: searchPatternPush. Required when command = push. Path to NuGet package(s) to publish. Default: $(Build.ArtifactStagingDirectory)/*.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. 
    #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).
    #packDirectory: '$(Build.ArtifactStagingDirectory)' # string. Alias: outputDir. Optional. Use when command = pack. Package Folder. Default: $(Build.ArtifactStagingDirectory).
    #nobuild: false # boolean. Optional. Use when command = pack. Do not build. Default: false.
    #includesymbols: false # boolean. Optional. Use when command = pack. Include Symbols. Default: false.
    #includesource: false # boolean. Optional. Use when command = pack. Include Source. Default: false.
  # 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 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.
    #restoreDirectory: # string. Alias: packagesDirectory. Optional. Use when command = restore. Destination directory. 
    #verbosityRestore: 'Detailed' # '-' | 'Quiet' | 'Minimal' | 'Normal' | 'Detailed' | 'Diagnostic'. 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.
  # Pack options
    #versioningScheme: 'off' # 'off' | 'byPrereleaseNumber' | 'byEnvVar' | 'byBuildNumber'. Required when command = pack. Automatic package versioning. Default: off.
    #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.
  # Advanced
    #buildProperties: # string. Optional. Use when command = pack. Additional build properties. 
    #verbosityPack: 'Detailed' # '-' | 'Quiet' | 'Minimal' | 'Normal' | 'Detailed' | 'Diagnostic'. Optional. Use when command = pack. Verbosity. Default: Detailed.
  # Advanced
    #workingDirectory: # string. Optional. Use when command != restore && command != push && command != pack && command != pack && command != push && command != restore. Working directory.
# .NET Core v2
# Build, test, package, or publish a dotnet application, or run a custom dotnet command.
- task: DotNetCoreCLI@2
  inputs:
    command: 'build' # 'build' | 'push' | 'pack' | 'publish' | 'restore' | 'run' | 'test' | 'custom'. Required. Command. Default: build.
    #publishWebProjects: true # boolean. Optional. Use when command = publish. Publish web projects. Default: true.
    #projects: # string. Optional. Use when command = build || command = restore || command = run || command = test || command = custom || publishWebProjects = false. Path to project(s). 
    #custom: # string. Required when command = custom. Custom command. 
    #arguments: # string. Optional. Use when command = build || command = publish || command = run || command = test || command = custom. Arguments. 
    #restoreArguments: # string. Optional. Use when command = restore. Arguments. 
    #publishTestResults: true # boolean. Optional. Use when command = test. Publish test results and code coverage. Default: true.
    #testRunTitle: # string. Optional. Use when command = test. Test run title. 
    #zipAfterPublish: true # boolean. Optional. Use when command = publish. Zip published projects. Default: true.
    #modifyOutputPath: true # boolean. Optional. Use when command = publish. Add project's folder name to publish path. Default: true.
    #packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg' # string. Alias: searchPatternPush. Required when command = push. Path to NuGet package(s) to publish. Default: $(Build.ArtifactStagingDirectory)/*.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. 
    #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).
    #packDirectory: '$(Build.ArtifactStagingDirectory)' # string. Alias: outputDir. Optional. Use when command = pack. Package Folder. Default: $(Build.ArtifactStagingDirectory).
    #nobuild: false # boolean. Optional. Use when command = pack. Do not build. Default: false.
    #includesymbols: false # boolean. Optional. Use when command = pack. Include Symbols. Default: false.
    #includesource: false # boolean. Optional. Use when command = pack. Include Source. Default: false.
  # 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 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.
    #restoreDirectory: # string. Alias: packagesDirectory. Optional. Use when command = restore. Destination directory. 
    #verbosityRestore: 'Detailed' # '-' | 'Quiet' | 'Minimal' | 'Normal' | 'Detailed' | 'Diagnostic'. 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.
  # Pack options
    #versioningScheme: 'off' # 'off' | 'byPrereleaseNumber' | 'byEnvVar' | 'byBuildNumber'. Required when command = pack. Automatic package versioning. Default: off.
    #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.
  # Advanced
    #buildProperties: # string. Optional. Use when command = pack. Additional build properties. 
    #verbosityPack: 'Detailed' # '-' | 'Quiet' | 'Minimal' | 'Normal' | 'Detailed' | 'Diagnostic'. Optional. Use when command = pack. Verbosity. Default: Detailed.
  # Advanced
    #workingDirectory: # string. Optional. Use when command != restore && command != push && command != pack && command != pack && command != push && command != restore. Working directory.
# .NET Core v2
# Build, test, package, or publish a dotnet application, or run a custom dotnet command.
- task: DotNetCoreCLI@2
  inputs:
    command: 'build' # 'build' | 'push' | 'pack' | 'publish' | 'restore' | 'run' | 'test' | 'custom'. Required. Command. Default: build.
    #publishWebProjects: true # boolean. Optional. Use when command = publish. Publish Web Projects. Default: true.
    #projects: # string. Optional. Use when command = build || command = restore || command = run || command = test || command = custom || publishWebProjects = false. Path to project(s). 
    #custom: # string. Required when command = custom. Custom command. 
    #arguments: # string. Optional. Use when command = build || command = publish || command = run || command = test || command = custom. Arguments. 
    #publishTestResults: true # boolean. Optional. Use when command = test. Publish test results and code coverage. Default: true.
    #testRunTitle: # string. Optional. Use when command = test. Test run title. 
    #zipAfterPublish: true # boolean. Optional. Use when command = publish. Zip Published Projects. Default: true.
    #modifyOutputPath: true # boolean. Optional. Use when command = publish. Add project name to publish path. Default: true.
    #packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg' # string. Alias: searchPatternPush. Required when command = push. Path to NuGet package(s) to publish. Default: $(Build.ArtifactStagingDirectory)/*.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. 
    #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).
    #packDirectory: '$(Build.ArtifactStagingDirectory)' # string. Alias: outputDir. Optional. Use when command = pack. Package Folder. Default: $(Build.ArtifactStagingDirectory).
    #nobuild: false # boolean. Optional. Use when command = pack. Do not build. Default: false.
    #includesymbols: false # boolean. Optional. Use when command = pack. Include Symbols. Default: false.
    #includesource: false # boolean. Optional. Use when command = pack. Include Source. Default: false.
  # 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 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.
    #restoreDirectory: # string. Alias: packagesDirectory. Optional. Use when command = restore. Destination directory. 
    #verbosityRestore: 'Detailed' # '-' | 'Quiet' | 'Minimal' | 'Normal' | 'Detailed' | 'Diagnostic'. 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.
  # Pack options
    #versioningScheme: 'off' # 'off' | 'byPrereleaseNumber' | 'byEnvVar' | 'byBuildNumber'. Required when command = pack. Automatic package versioning. Default: off.
    #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.
  # Advanced
    #buildProperties: # string. Optional. Use when command = pack. Additional build properties. 
    #verbosityPack: 'Detailed' # '-' | 'Quiet' | 'Minimal' | 'Normal' | 'Detailed' | 'Diagnostic'. Optional. Use when command = pack. Verbosity. Default: Detailed.
  # Advanced
    #workingDirectory: # string. Optional. Use when command != pack && command != push && command != restore. Working Directory.
# .NET Core v2
# Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
- task: DotNetCoreCLI@2
  inputs:
    command: 'build' # 'build' | 'push' | 'pack' | 'publish' | 'restore' | 'run' | 'test' | 'custom'. Required. Command. Default: build.
    #publishWebProjects: true # boolean. Optional. Use when command = publish. Publish Web Projects. Default: true.
    #projects: # string. Optional. Use when command = build || command = restore || command = run || command = test || command = custom || publishWebProjects = false. Path to project(s). 
    #custom: # string. Required when command = custom. Custom command. 
    #arguments: # string. Optional. Use when command = build || command = publish || command = run || command = test || command = custom. Arguments. 
    #publishTestResults: true # boolean. Optional. Use when command = test. Publish test results and code coverage. Default: true.
    #zipAfterPublish: true # boolean. Optional. Use when command = publish. Zip Published Projects. Default: true.
    #modifyOutputPath: true # boolean. Optional. Use when command = publish. Add project name to publish path. Default: true.
    #packagesToPush: '$(Build.ArtifactStagingDirectory)/*.nupkg' # string. Alias: searchPatternPush. Required when command = push. Path to NuGet package(s) to publish. Default: $(Build.ArtifactStagingDirectory)/*.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. 
    #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).
    #packDirectory: '$(Build.ArtifactStagingDirectory)' # string. Alias: outputDir. Optional. Use when command = pack. Package Folder. Default: $(Build.ArtifactStagingDirectory).
    #nobuild: false # boolean. Optional. Use when command = pack. Do not build. Default: false.
  # 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.
    #restoreDirectory: # string. Alias: packagesDirectory. Optional. Use when command = restore. Destination directory. 
    #verbosityRestore: 'Detailed' # '-' | 'Quiet' | 'Minimal' | 'Normal' | 'Detailed' | 'Diagnostic'. Optional. Use when command = restore. Verbosity. Default: Detailed.
  # Pack options
    #versioningScheme: 'off' # 'off' | 'byPrereleaseNumber' | 'byEnvVar' | 'byBuildNumber'. Required when command = pack. Automatic package versioning. Default: off.
    #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.
  # Advanced
    #buildProperties: # string. Optional. Use when command = pack. Additional build properties. 
    #verbosityPack: 'Detailed' # '-' | 'Quiet' | 'Minimal' | 'Normal' | 'Detailed' | 'Diagnostic'. Optional. Use when command = pack. Verbosity. Default: Detailed.
  # Advanced
    #workingDirectory: # string. Optional. Use when command != pack && command != push && command != restore. Working Directory.

入力

command - コマンド
string. 必須です。 使用できる値: build、(nuget push)publishpack、、restorerun、、testcustompush 既定値: build

実行する DotNet コマンド。 引数を追加するか、ここに記載されていないコマンドを使用するように指定 custom します。

重要

[NuGet 認証] タスクは、Azure Artifacts などの NuGet リポジトリで認証するための新しい推奨される方法です。 この .NET Core CLI タスクの コマンドと push コマンドはrestore新機能を使用しなくなり、重大なバグのみが対処されます。 詳細については、「解説」を参照してください。


publishWebProjects - Web プロジェクトを発行する
boolean. 省略可能。 の場合は command = publishを使用します。 既定値: true

この入力が に true設定されている場合、プロパティ値 projects はスキップされ、タスクはリポジトリ内の Web プロジェクトを検索し、それらに対して publish コマンドを実行しようとします。 Web プロジェクトは、ディレクトリ内に web.config ファイルまたは wwwroot フォルダーが存在することによって識別されます。 ファイルまたはwwwrootフォルダーがないweb.config場合は、 などの Microsoft.NET.Sdk.WebWeb SDK を使用するプロジェクトが選択されます。


publishWebProjects - Web プロジェクトの発行
boolean. 省略可能。 の場合は command = publishを使用します。 既定値: true

この入力が に true設定されている場合、プロパティ値 projects はスキップされ、タスクはリポジトリ内の Web プロジェクトを検索し、それらに対して publish コマンドを実行しようとします。 Web プロジェクトは、ディレクトリ内に web.config ファイルまたは wwwroot フォルダーが存在することによって識別されます。 ファイルまたはwwwrootフォルダーがないweb.config場合は、 などの Microsoft.NET.Sdk.WebWeb SDK を使用するプロジェクトが選択されます。


projects - プロジェクトまたはソリューションへのパス
string. 省略可能。 の場合は command = build || command = restore || command = run || command = test || command = custom || publishWebProjects = falseを使用します。

使用する または .sln ファイルへの.csprojパス。 ワイルドカードを使用できます (たとえば **/*.csproj 、すべてのサブフォルダー内のすべての .csproj ファイルに対して)。 詳細については、 ファイル 一致パターンのリファレンスを参照してください

このパスは、設定に関係なく、リポジトリのルートに対する workingDirectory 相対パスです。


projects - プロジェクトへのパス
string. 省略可能。 の場合は command = build || command = restore || command = run || command = test || command = custom || publishWebProjects = falseを使用します。

使用する .csproj ファイルのパス。 ワイルドカードを使用できます (たとえば **/*.csproj 、すべてのサブフォルダー内のすべての .csproj ファイルに対して)。 詳細については、 ファイル 一致パターンのリファレンスを参照してください

このパスは、設定に関係なく、リポジトリのルートに対する workingDirectory 相対パスです。


custom - カスタム コマンド
string. command = custom の場合に必要です。

実行に渡す dotnet.exe コマンド。 使用可能なコマンドの完全な一覧については、 dotnet CLI のドキュメントを参照してください


arguments - 引数
string. 省略可能。 の場合は command = build || command = publish || command = run || command = test || command = customを使用します。

選択したコマンドの引数を指定します。 たとえば、ビルド構成、出力フォルダー、ランタイムなどです。 引数は、選択したコマンドによって異なります。

現在、この入力は、、publishtestrunおよび custombuild引数のみを受け入れます。 リストされていないコマンドの引数を追加する場合は、custom を使用します。


restoreArguments - 引数
string. 省略可能。 の場合は command = restoreを使用します。

コマンドに渡される追加の引数を restore 書き込みます。


publishTestResults - テスト結果とコード カバレッジを発行する
boolean. 省略可能。 の場合は command = testを使用します。 既定値: true

このオプションを有効にすると、 で $(Agent.TempDirectory)TRX ファイルが生成test resultsされ、結果がサーバーに発行されます。

このオプションにより、コマンドライン引数に --logger trx --results-directory $(Agent.TempDirectory) が追加されます。

コマンド ライン引数に オプションを --collect "Code coverage" 追加することで、コード カバレッジを収集できます。


testRunTitle - テスト実行のタイトル
string. 省略可能。 の場合は command = testを使用します。

テスト実行の名前を提供します。


zipAfterPublish - Zip 発行済みプロジェクト
boolean. 省略可能。 の場合は command = publishを使用します。 既定値: true

この入力が に true設定されている場合、publish コマンドによって作成されたフォルダーは圧縮されて削除されます。


zipAfterPublish - Zip 発行済みプロジェクト
boolean. 省略可能。 の場合は command = publishを使用します。 既定値: true

この入力が に true設定されている場合、publish コマンドによって作成されたフォルダーは圧縮されて削除されます。


modifyOutputPath - プロジェクトのフォルダー名を発行パスに追加する
boolean. 省略可能。 の場合は command = publishを使用します。 既定値: true

この入力が に true設定されている場合、publish コマンドによって作成されたフォルダーには、出力パスが引数で明示的に指定されている場合、プロジェクト ファイル名の前にフォルダー名が付けられます。 これは、複数のプロジェクトを同一のフォルダーに発行する場合に便利です。


modifyOutputPath - 発行パスにプロジェクト名を追加する
boolean. 省略可能。 の場合は command = publishを使用します。 既定値: true

この入力が に true設定されている場合、publish コマンドによって作成されたフォルダーには、出力パスが引数で明示的に指定されている場合、プロジェクト ファイル名の前にフォルダー名が付けられます。 これは、複数のプロジェクトを同一のフォルダーに発行する場合に便利です。


feedsToUse - 使用するフィード
入力エイリアス: selectOrConfigstring. command = restore の場合に必要です。 使用できる値: select (ここで選択したフィード) config 、(NuGet.config のフィード)。 既定値: select

Azure Artifacts や NuGet.org ここからフィードを選択するか、ファイルをソース コード リポジトリにコミット nuget.config し、入力を使用してそのパスを nugetConfigPath 設定できます。


vstsFeed - この Azure Artifacts フィードのパッケージを使用する
入力エイリアス: feedRestorestring. 省略可能。 の場合は selectOrConfig = select && command = restoreを使用します。

生成 NuGet.configされた に選択したフィードが含まれます。 ここでフィードを選択するには、パッケージ管理がインストールされ、ライセンスが必要です。 projectName/feedName は、プロジェクト スコープのフィードに使用されます。 organization範囲のフィードにのみFeedName使用されます。 注: これはテスト コマンドではサポートされていません。


vstsFeed - この Azure Artifacts/TFS フィードのパッケージを使用する
入力エイリアス: feedRestorestring. 省略可能。 の場合は selectOrConfig = select && command = restoreを使用します。

生成 NuGet.configされた に選択したフィードが含まれます。 ここでフィードを選択するには、パッケージ管理がインストールされ、ライセンスが必要です。 projectName/feedName は、プロジェクト スコープのフィードに使用されます。 organization範囲のフィードにのみFeedName使用されます。 注: これはテスト コマンドではサポートされていません。


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/コレクション外のフィードの資格情報
入力エイリアス: externalEndpointsstring. 省略可能。 の場合は selectOrConfig = config && command = restoreを使用します。

選択した NuGet.configにある外部レジストリに使用する資格情報。 このorganization/コレクション内のフィードの場合は、この入力を空白のままにします。ビルドの資格情報は自動的に使用されます。


noCache - ローカル キャッシュを無効にする
boolean. 省略可能。 の場合は command = restoreを使用します。 既定値: false

NuGet で、ローカル コンピューターのキャッシュからパッケージを使用しないようにします。


restoreDirectory - 宛先ディレクトリ
入力エイリアス: packagesDirectorystring. 省略可能。 の場合は command = restoreを使用します。

パッケージのインストール先フィルダーを指定します。 フォルダーが指定されていない場合、パッケージは既定の NuGet パッケージ キャッシュに復元されます。


verbosityRestore - 詳細
string. 省略可能。 の場合は command = restoreを使用します。 使用できる値: -、、QuietMinimalNormalDetailedDiagnostic 既定値: Detailed

restore コマンドの出力に表示される詳細の量を指定します。


packagesToPush - 発行する NuGet パッケージへのパス
入力エイリアス: searchPatternPushstring. command = push の場合に必要です。 既定値: $(Build.ArtifactStagingDirectory)/*.nupkg

一致するパターン、またはアップロードするファイルへの nupkg パス。 複数のパターンはセミコロンで区切ることができます。パターンの前に ! を付けることで否定のパターンにすることができます。 例: **/*.nupkg;!**/*.Tests.nupkg.


nuGetFeedType - ターゲット フィードの場所
string. command = push の場合に必要です。 使用できる値: internal (このorganization/コレクション) external 、(外部 NuGet サーバー (他の組織/コレクションを含む)。 既定値: internal

ターゲット フィードが内部であるか外部であるかを指定します。


publishVstsFeed - ターゲット フィード
入力エイリアス: feedPublishstring. command = push && nuGetFeedType = internal の場合に必要です。

このorganizationでホストされるフィードを指定します。 ここでフィードを選択するには、パッケージ管理がインストールされ、ライセンスが必要です。


publishPackageMetadata - パイプライン メタデータを発行する
boolean. 省略可能。 の場合は command = push && nuGetFeedType = internal && command = pushを使用します。 既定値: true

このビルド/リリース パイプラインのメタデータ (実行 #、ソース コード情報) をパッケージに関連付けます。


publishFeedCredentials - NuGet サーバー
入力エイリアス: externalEndpointstring. command = push && nuGetFeedType = external の場合に必要です。

外部 NuGet サーバーの資格情報を含む NuGet サービス接続


packagesToPack - パックする csproj または nuspec ファイルへのパス
入力エイリアス: searchPatternPackstring. command = pack の場合に必要です。 既定値: **/*.csproj

パックするまたは.nuspecファイルを.csproj検索するパターン。

セミコロンで複数のパターンを区切ることができます。パターンの前に ! を付けることで否定のパターンにすることができます。 例: **/*.csproj;!**/*.Tests.csproj.


configuration - パッケージへの構成
入力エイリアス: configurationToPackstring. 省略可能。 の場合は command = packを使用します。 既定値: $(BuildConfiguration)

ファイルを使用する .csproj 場合、この入力はパッケージ化する構成を指定します。


packDirectory - パッケージ フォルダー
入力エイリアス: outputDirstring. 省略可能。 の場合は command = packを使用します。 既定値: $(Build.ArtifactStagingDirectory)

パッケージが作成されるフォルダー。 このフォルダーが空の場合、パッケージはファイルと共に csproj 作成されます。


nobuild - ビルドしない
boolean. 省略可能。 の場合は command = packを使用します。 既定値: false

タスクがパッケージ化する前にプロジェクトをビルドしないことを指定します。 このタスクは、 コマンドの --no-build パラメーターに build 対応します。


includesymbols - シンボルを含める
boolean. 省略可能。 の場合は command = packを使用します。 既定値: false

シンボル NuGet パッケージを作成します。 このタスクは、コマンド ライン パラメーターに --include-symbols 対応します。


includesource - ソースを含める
boolean. 省略可能。 の場合は command = packを使用します。 既定値: false

パッケージにソース コードを含めます。 このタスクは、コマンド ライン パラメーターに --include-source 対応します。


versioningScheme - パッケージの自動バージョン管理
string. command = pack の場合に必要です。 使用できる値: offbyPrereleaseNumber (日付と時刻を使用) byEnvVar 、(環境変数を使用) byBuildNumber 、(ビルド番号を使用)。 既定値: off

このタスクは、参照先プロジェクトを含むには使用できません。 を選択すると、および Zを選択YUse the date and timeXした場所としてX.Y.Z-ci-datetime書式設定された SemVer 準拠バージョンが生成されます。

Use an environment variable を選択する場合は、環境変数を選択し、使用するバージョン番号が含まれていることを確認する必要があります。

Use the build number を選択すると、ビルド番号を使用してパッケージのバージョンが管理されます。 メモ:Options、ビルド番号の形式を に $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)設定します。


versionEnvVar - 環境変数
string. versioningScheme = byEnvVar && command = pack の場合に必要です。

、、または %を使用せずに$$env変数名を指定します。


majorVersion - 主要
入力エイリアス: requestedMajorVersionstring. versioningScheme = byPrereleaseNumber && command = pack の場合に必要です。 既定値: 1

Xバージョン X.Y.Z の


minorVersion - マイナー
入力エイリアス: requestedMinorVersionstring. versioningScheme = byPrereleaseNumber && command = pack の場合に必要です。 既定値: 0

Yバージョン X.Y.Z の


patchVersion - パッチ
入力エイリアス: requestedPatchVersionstring. versioningScheme = byPrereleaseNumber && command = pack の場合に必要です。 既定値: 0

Zバージョン X.Y.Z の


buildProperties - 追加のビルド プロパティ
string. 省略可能。 の場合は command = packを使用します。

ペアのtoken = value一覧をセミコロンで区切って指定します。ここで、ファイル内の .nuspec$token$各出現箇所は、指定された値に置き換えられます。 値には、引用符で囲まれた文字列を指定できます。


verbosityPack - 詳細
string. 省略可能。 の場合は command = packを使用します。 使用できる値: -、、QuietMinimalNormalDetailedDiagnostic 既定値: Detailed

pack コマンドの出力に表示される詳細の量を指定します。


workingDirectory - 作業ディレクトリ
string. 省略可能。 の場合は command != restore && command != push && command != pack && command != pack && command != push && command != restoreを使用します。

スクリプトが実行されている現在の作業ディレクトリ。 Empty は、リポジトリ (ビルド) または成果物 (リリース) のルートです。これは です $(System.DefaultWorkingDirectory)


workingDirectory - 作業ディレクトリ
string. 省略可能。 の場合は command != pack && command != push && command != restoreを使用します。

スクリプトが実行されている現在の作業ディレクトリ。 Empty は、リポジトリ (ビルド) または成果物 (リリース) のルートです。これは です $(System.DefaultWorkingDirectory)


タスク制御オプション

すべてのタスクには、タスク入力に加えて制御オプションがあります。 詳細については、「 コントロール オプションと一般的なタスク プロパティ」を参照してください。

出力変数

[なし] :

解説

重要

[NuGet 認証] タスクは、Azure Artifacts などの NuGet リポジトリで認証するための新しい推奨される方法です。 この .NET Core CLI タスクの コマンドと push コマンドはrestore新機能を使用しなくなり、重大なバグのみが対処されます。

ビルド、発行、またはテストのステップでパッケージの復元に失敗するのはなぜですか?

ほとんどの dotnet コマンド (buildpublishtest を含む) には、暗黙的な restore ステップが含まれています。 これは、前のステップで dotnet restore が正常に実行されていた場合でも、認証されたフィードに対して失敗します。その理由は、前のステップで使用した資格情報がクリーンアップされるためです。

この問題を解決するには、テキスト ボックスに --no-restore フラグを Arguments 追加します。

さらに、コマンドは test または 引数をfeedRestore認識せず、この方法で指定されたフィードは、暗黙的なrestoreステップの実行時に生成されたNuGet.configファイルvstsFeedに含まれません。 パッケージを復元するには、明示的 dotnet restore な手順を使用することをお勧めします。 restore コマンドは、引数の feedRestorevstsFeed を考慮します。

マシンでビルドするときに警告がないのに、 パッケージ ソース マッピング で NU1507 警告が表示されるのはなぜですか?

NuGet の復元または NuGet フィードへのアクセスを行うさまざまなコマンドは、Azure 成果物 NuGet フィードの NuGet 認証を追加する特別な一時 NuGet.config ファイルをビルドします。 この方法は、パッケージ ソース マッピングがパッケージをソースにマップするために使用するスキーマと競合し、リポジトリ内のファイル内のパッケージ ソース マップピン構成が NuGet.config 中断されます。 この競合を回避するには、 NuGet 認証 タスクを使用して認証し、その後カスタム コマンドを使用して、変更なしで目的の dotnet コマンドを NuGet.config 呼び出すことができます。

# Authenticate Azure DevOps NuGet feed
- task: NuGetAuthenticate@1
  displayName: 'Authenticate Azure DevOps NuGet feed'

# Restore project
- task: DotNetCoreCLI@2
  inputs:
    command: 'custom'
    custom: 'restore'

# Build project
- task: DotNetCoreCLI@2
  inputs:
    command: 'custom'
    custom: 'build'
    arguments: '--no-restore'

なぜ NuGet.config のチェックインが必要なのですか?

NuGet.configをソース管理にチェックインすると、プロジェクトのビルドに必要な重要な情報 (パッケージの場所) を、コードをチェックアウトするすべての開発者が利用できるようになります。

ただし、開発者のチームがさまざまなプロジェクトに取り組む状況では、各開発者のマシン上のグローバル NuGet.config に Azure Artifacts フィードを追加することもできます。 このような状況では、NuGet タスクで オプションを使用すると Feeds I select here 、この構成がレプリケートされます。

トラブルシューティング

Entity Framework を使用するプロジェクトがホステッド エージェントでの作業を停止しました

.NET Core には Entity Framework(EF) が組み込まれていません。 実行を開始する前に EF をインストールするか、必要な .NET Core SDK バージョンでプロジェクトに追加 global.json する必要があります。 これにより、EF プロジェクトのビルドには正しい SDK が使用されるようになります。 必要なバージョンがマシンに存在しない場合は、タスクを UseDotNetV2 パイプラインに追加して、必要なバージョンをインストールします。 詳細については、「 Entity Framework Core ランタイムを取得する」を参照してください。

ビルド例

プロジェクトのビルド

# Build project
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'

複数のプロジェクトのビルド

# Build multiple projects
- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: |
      src/proj1/proj1.csproj 
      src/proj2/proj2.csproj 
      src/other/other.sln    # Pass a solution instead of a csproj.

プッシュの例

NuGet パッケージを内部フィードにプッシュする

# Push non test NuGet packages from a build to internal organization Feed
- task: DotNetCoreCLI@2
  inputs:
    command: 'push'
    searchPatternPush: '$(Build.ArtifactStagingDirectory)/*.nupkg;!$(Build.ArtifactStagingDirectory)/*.Tests.nupkg'
    feedPublish: 'FabrikamFeed'

NuGet パッケージを外部フィードにプッシュする

# Push all NuGet packages from a build to external Feed
- task: DotNetCoreCLI@2
  inputs:
    command: 'push'
    nugetFeedType: 'external'
    externalEndPoint: 'MyNuGetServiceConnection'

パックの例

特定の出力ディレクトリに NuGetPackage をパックする

# Pack a NuGet package to a test directory
- task: DotNetCoreCLI@2
  inputs: 
    command: 'pack'
    outputDir: '$(Build.ArtifactStagingDirectory)/TestDir'

シンボル パッケージをパックする

# Pack a symbol package along with NuGet package
- task: DotNetCoreCLI@2
  inputs: 
    command: 'pack'
    includesymbols: true

発行の例

指定したフォルダーにプロジェクトを発行する

# Publish projects to specified folder.
- task: DotNetCoreCLI@2
  displayName: 'dotnet publish'
  inputs:
    command: 'publish'
    publishWebProjects: false
    projects: '**/*.csproj'
    arguments: '-o $(Build.ArtifactStagingDirectory)/Output'
    zipAfterPublish: true
    modifyOutputPath: true

復元の例

#Restore packages with the .NET Core CLI task
- task: DotNetCoreCLI@2
  displayName: 'dotnet restore'
  inputs:
    command: 'restore'
    feedsToUse: 'select'
    feedRestore: 'projectName/feedName'
    projects: '**/*.csproj'
    includeNuGetOrg: true

テストの例

リポジトリ内でテストを実行する

# Run tests and auto publish test results.
- task: DotNetCoreCLI@2
  inputs:
    command: 'test'

要件

要件 説明
パイプラインの種類 YAML、クラシック ビルド、クラシック リリース
実行日 エージェント
確認要求 なし
Capabilities このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。
コマンドの制限 Any
設定可能な変数 Any
エージェントのバージョン 2.144.0 以上
タスクのカテゴリ Build
要件 説明
パイプラインの種類 YAML、クラシック ビルド、クラシック リリース
実行日 エージェント
確認要求 なし
Capabilities このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。
コマンドの制限 Any
設定可能な変数 Any
エージェントのバージョン 2.115.0 以上
タスクのカテゴリ Build
要件 説明
パイプラインの種類 YAML、クラシック ビルド、クラシック リリース
実行日 エージェント
確認要求 なし
Capabilities このタスクは、ジョブ内の後続のタスクに対する要求を満たしていません。
コマンドの制限 Any
設定可能な変数 Any
エージェントのバージョン 2.0.0 以上
タスクのカテゴリ Build