DotNetCoreCLI@2 - .NET Core v2 task

Build, test, package, or publish a .NET application, or run a custom .NET CLI command.

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.

Important

The NuGet Authenticate task is the new recommended way to authenticate with Azure Artifacts and other NuGet repositories. The restore and push commands of this .NET Core CLI task no longer take new features and only critical bugs are addressed. See remarks for details.

Syntax

# .NET Core v2
# Build, test, package, or publish a .NET application, or run a custom .NET CLI command.
- task: DotNetCoreCLI@2
  inputs:
    #azureSubscription: # string. Alias: ConnectedServiceName. Azure Resource Manager connection. 
    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.
    #requestTimeout: '300000' # string. Set timeout for package download request. Default: 300000.
  # 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. Select from the dropdown or enter [project name/]feed name. 
    #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: 'Normal' # '-' | 'Quiet' | 'Minimal' | 'Normal' | 'Detailed' | 'Diagnostic'. Optional. Use when command = restore. Verbosity. Default: Normal.
  # 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: 'Normal' # '-' | 'Quiet' | 'Minimal' | 'Normal' | 'Detailed' | 'Diagnostic'. Optional. Use when command = pack. Verbosity. Default: Normal.
  # 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 .NET application, or run a custom .NET CLI 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 .NET application, or run a custom .NET CLI 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 .NET application, or run a custom .NET CLI 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 .NET application, or run a custom .NET CLI 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.
    #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.

Inputs

azureSubscription - Azure Resource Manager connection
Input alias: ConnectedServiceName. string.

Specify an Azure Resource Manager service connection configured with workload identity federation to use AzurePipelinesCredential in integration tests. For more information, see Use AzurePipelinesCredential in integration tests.

Note

This input only supports ARM service connections that are configured to use workload identity federation.


command - Command
string. Required. Allowed values: build, push (nuget push), pack, publish, restore, run, test, custom. Default value: build.

The dotnet command to run. Specify custom to add arguments or use a command not listed here.

Important

The NuGet Authenticate task is the new recommended way to authenticate with Azure Artifacts and other NuGet repositories. The restore and push commands of this .NET Core CLI task no longer take new features and only critical bugs are addressed. See remarks for details.


publishWebProjects - Publish web projects
boolean. Optional. Use when command = publish. Default value: true.

If this input is set to true, the projects property value is skipped, and the task tries to find the web projects in the repository and run the publish command on them. Web projects are identified by the presence of either a web.config file or a wwwroot folder in the directory. In the absence of a web.config file or a wwwroot folder, projects that use a web SDK, like Microsoft.NET.Sdk.Web, are selected.


publishWebProjects - Publish Web Projects
boolean. Optional. Use when command = publish. Default value: true.

If this input is set to true, the projects property value is skipped, and the task tries to find the web projects in the repository and run the publish command on them. Web projects are identified by the presence of either a web.config file or a wwwroot folder in the directory. In the absence of a web.config file or a wwwroot folder, projects that use a web SDK, like Microsoft.NET.Sdk.Web, are selected.


projects - Path to project(s) or solution(s)
string. Optional. Use when command = build || command = restore || command = run || command = test || command = custom || publishWebProjects = false.

The path to the .csproj or .sln file(s) to use. You can use wildcards (e.g. **/*.csproj for all .csproj files in all subfolders). For more information, see the file matching patterns reference.

This path is relative to the root of the repository regardless of the workingDirectory setting.


projects - Path to project(s)
string. Optional. Use when command = build || command = restore || command = run || command = test || command = custom || publishWebProjects = false.

The path to the .csproj file(s) to use. You can use wildcards (e.g. **/*.csproj for all .csproj files in all subfolders). For more information, see the file matching patterns reference.

This path is relative to the root of the repository regardless of the workingDirectory setting.


custom - Custom command
string. Required when command = custom.

The command to pass to dotnet.exe for execution. For a full list of available commands, see the dotnet CLI documentation.


arguments - Arguments
string. Optional. Use when command = build || command = publish || command = run || command = test || command = custom.

Specifies the arguments for the selected command. For example, build configuration, output folder, and runtime. The arguments depend on the command selected.

This input currently only accepts arguments for build, publish, run, test, and custom. If you would like to add arguments for a command not listed, use custom.


restoreArguments - Arguments
string. Optional. Use when command = restore.

Writes the additional arguments to be passed to the restore command.


publishTestResults - Publish test results and code coverage
boolean. Optional. Use when command = test. Default value: true.

Enabling this option will generate a test results TRX file in $(Agent.TempDirectory), and the results will be published to the server.

This option appends --logger trx --results-directory $(Agent.TempDirectory) to the command line arguments.

Code coverage can be collected by adding the --collect "Code coverage" option to the command line arguments.


testRunTitle - Test run title
string. Optional. Use when command = test.

Provides a name for the test run.


zipAfterPublish - Zip published projects
boolean. Optional. Use when command = publish. Default value: true.

If this input is set to true, folders created by the publish command will be zipped and deleted.


zipAfterPublish - Zip Published Projects
boolean. Optional. Use when command = publish. Default value: true.

If this input is set to true, the folder created by the publish command will be zipped and deleted.


modifyOutputPath - Add project's folder name to publish path
boolean. Optional. Use when command = publish. Default value: true.

If this input is set to true, folders created by the publish command will have the project file name prefixed to their folder names when the output path is specified explicitly in arguments. This is useful if you want to publish multiple projects to the same folder.


modifyOutputPath - Add project name to publish path
boolean. Optional. Use when command = publish. Default value: true.

If this input is set to true, folders created by the publish command will have the project file name prefixed to their folder names when the output path is specified explicitly in arguments. This is useful if you want to publish multiple projects to the same folder.


feedsToUse - Feeds to use
Input alias: selectOrConfig. string. Required when command = restore. Allowed values: select (Feed(s) I select here), config (Feeds in my NuGet.config). Default value: select.

You can either select a feed from Azure Artifacts and/or NuGet.org here, or you can commit a nuget.config file to your source code repository and set its path using the nugetConfigPath input.


vstsFeed - Use packages from this Azure Artifacts feed. Select from the dropdown or enter [project name/]feed name.
Input alias: feedRestore. string. Optional. Use when selectOrConfig = select && command = restore.

Includes the selected feed in the generated NuGet.config. You must have Package Management installed and licensed to select a feed here. projectName/feedName are used for project-scoped feeds. Only FeedName is used for organization-scoped feeds. Note: This is not supported for the test command.


vstsFeed - Use packages from this Azure Artifacts feed
Input alias: feedRestore. string. Optional. Use when selectOrConfig = select && command = restore.

Includes the selected feed in the generated NuGet.config. You must have Package Management installed and licensed to select a feed here. projectName/feedName are used for project-scoped feeds. Only FeedName is used for organization-scoped feeds. Note: This is not supported for the test command.


vstsFeed - Use packages from this Azure Artifacts/TFS feed
Input alias: feedRestore. string. Optional. Use when selectOrConfig = select && command = restore.

Includes the selected feed in the generated NuGet.config. You must have Package Management installed and licensed to select a feed here. projectName/feedName are used for for project-scoped feeds. Only FeedName is used for organization-scoped feeds. Note: This is not supported for the test command.


includeNuGetOrg - Use packages from NuGet.org
boolean. Optional. Use when selectOrConfig = select && command = restore. Default value: true.

Includes NuGet.org in the generated NuGet.config.


nugetConfigPath - Path to NuGet.config
string. Optional. Use when selectOrConfig = config && command = restore.

The NuGet.config in your repository that specifies the feeds from which to restore packages.


externalFeedCredentials - Credentials for feeds outside this organization/collection
Input alias: externalEndpoints. string. Optional. Use when selectOrConfig = config && command = restore.

The credentials to use for external registries located in the selected NuGet.config. For feeds in this organization/collection, leave this input blank; the build's credentials are used automatically.


noCache - Disable local cache
boolean. Optional. Use when command = restore. Default value: false.

Prevents NuGet from using packages from local machine caches.


restoreDirectory - Destination directory
Input alias: packagesDirectory. string. Optional. Use when command = restore.

Specifies the folder in which packages are installed. If no folder is specified, packages are restored into the default NuGet package cache.


verbosityRestore - Verbosity
string. Optional. Use when command = restore. Allowed values: -, Quiet, Minimal, Normal, Detailed, Diagnostic. Default value: Normal.

Specifies the amount of detail displayed in the output for the restore command.


verbosityRestore - Verbosity
string. Optional. Use when command = restore. Allowed values: -, Quiet, Minimal, Normal, Detailed, Diagnostic. Default value: Detailed.

Specifies the amount of detail displayed in the output for the restore command.


packagesToPush - Path to NuGet package(s) to publish
Input alias: searchPatternPush. string. Required when command = push. Default value: $(Build.ArtifactStagingDirectory)/*.nupkg.

The pattern to match or path to nupkg files to be uploaded. Multiple patterns can be separated by a semicolon, and you can make a pattern negative by prefixing it with !. Example: **/*.nupkg;!**/*.Tests.nupkg.


nuGetFeedType - Target feed location
string. Required when command = push. Allowed values: internal (This organization/collection), external (External NuGet server (including other organizations/collections)). Default value: internal.

Specifies whether the target feed is internal or external.


publishVstsFeed - Target feed
Input alias: feedPublish. string. Required when command = push && nuGetFeedType = internal.

Specifies a feed hosted in this organization. You must have Package Management installed and licensed to select a feed here.


publishPackageMetadata - Publish pipeline metadata
boolean. Optional. Use when command = push && nuGetFeedType = internal && command = push. Default value: true.

Associates this build/release pipeline's metadata (run #, source code information) with the package.


publishFeedCredentials - NuGet server
Input alias: externalEndpoint. string. Required when command = push && nuGetFeedType = external.

The NuGet service connection that contains the external NuGet server's credentials.


packagesToPack - Path to csproj or nuspec file(s) to pack
Input alias: searchPatternPack. string. Required when command = pack. Default value: **/*.csproj.

The pattern to search for .csproj or .nuspec files to pack.

You can separate multiple patterns with a semicolon, and you can make a pattern negative by prefixing it with !. Example: **/*.csproj;!**/*.Tests.csproj.


configuration - Configuration to Package
Input alias: configurationToPack. string. Optional. Use when command = pack. Default value: $(BuildConfiguration).

When using a .csproj file, this input specifies the configuration to package.


packDirectory - Package Folder
Input alias: outputDir. string. Optional. Use when command = pack. Default value: $(Build.ArtifactStagingDirectory).

The folder where packages will be created. If this folder is empty, packages will be created alongside the csproj file.


nobuild - Do not build
boolean. Optional. Use when command = pack. Default value: false.

Specifies that the task will not build the project before packing. This task corresponds to the --no-build parameter of the build command.


includesymbols - Include Symbols
boolean. Optional. Use when command = pack. Default value: false.

Creates symbol NuGet packages. This task corresponds to the --include-symbols command line parameter.


includesource - Include Source
boolean. Optional. Use when command = pack. Default value: false.

Includes source code in the package. This task corresponds to the --include-source command line parameter.


versioningScheme - Automatic package versioning
string. Required when command = pack. Allowed values: off, byPrereleaseNumber (Use the date and time), byEnvVar (Use an environment variable), byBuildNumber (Use the build number). Default value: off.

This task cannot be used with included referenced projects. If you choose Use the date and time, this will generate a SemVer-compliant version formatted as X.Y.Z-ci-datetime where you choose X, Y, and Z.

If you choose Use an environment variable, you must select an environment variable and ensure it contains the version number you want to use.

If you choose Use the build number, this will use the build number to version your package. Note: Under Options, set the build number format to $(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r).


versionEnvVar - Environment variable
string. Required when versioningScheme = byEnvVar && command = pack.

Specifies the variable name without $, $env, or %.


majorVersion - Major
Input alias: requestedMajorVersion. string. Required when versioningScheme = byPrereleaseNumber && command = pack. Default value: 1.

The X in version X.Y.Z.


minorVersion - Minor
Input alias: requestedMinorVersion. string. Required when versioningScheme = byPrereleaseNumber && command = pack. Default value: 0.

The Y in version X.Y.Z.


patchVersion - Patch
Input alias: requestedPatchVersion. string. Required when versioningScheme = byPrereleaseNumber && command = pack. Default value: 0.

The Z in version X.Y.Z.


buildProperties - Additional build properties
string. Optional. Use when command = pack.

Specifies a list of token = value pairs, separated by semicolons, where each occurrence of $token$ in the .nuspec file will be replaced with the given value. Values can be strings in quotation marks.


verbosityPack - Verbosity
string. Optional. Use when command = pack. Allowed values: -, Quiet, Minimal, Normal, Detailed, Diagnostic. Default value: Normal.

Specifies the amount of detail displayed in the output for the pack command.


verbosityPack - Verbosity
string. Optional. Use when command = pack. Allowed values: -, Quiet, Minimal, Normal, Detailed, Diagnostic. Default value: Detailed.

Specifies the amount of detail displayed in the output for the pack command.


workingDirectory - Working directory
string. Optional. Use when command != restore && command != push && command != pack && command != pack && command != push && command != restore.

The current working directory where the script is run. Empty is the root of the repo (build) or artifacts (release), which is $(System.DefaultWorkingDirectory).


workingDirectory - Working Directory
string. Optional. Use when command != pack && command != push && command != restore.

The current working directory where the script is run. Empty is the root of the repo (build) or artifacts (release), which is $(System.DefaultWorkingDirectory).


requestTimeout - Set timeout for package download request
string. Default value: 300000.

Provide a timeout value for HTTP requests that the task makes to obtain the .NET package. The value is in milliseconds. Default is 300000 milliseconds (5 minutes). Cannot be more than 600000 milliseconds (10 minutes).


Task control options

All tasks have control options in addition to their task inputs. For more information, see Control options and common task properties.

Output variables

None.

Remarks

Important

The NuGet Authenticate task is the new recommended way to authenticate with Azure Artifacts and other NuGet repositories. The restore and push commands of this .NET Core CLI task no longer take new features and only critical bugs are addressed.

Use AzurePipelinesCredential in integration tests

The Azure Identity libraries for .NET, C++, Go, Java, JavaScript, and Python provide support for workload identity federation, so code executed from the AzureCLI@2 and AzurePowerShell@5 tasks can authenticate with Microsoft Entra ID (for example, to access Azure) using the AzurePipelinesCredential class.

Many customers are using Azure SDK client libraries in integration tests invoked from other tasks. The DotNetCoreCLI@2, Maven@4 and VSTest@3 tasks can access Azure resources using the AzurePipelinesCredential class.

You can set the connectedServiceName property to an Azure service connection configured with workload identity federation. The AzurePipelinesCredential requires SYSTEM_ACCESSTOKEN to be set.

The following example shows the connectedServiceName input on the DotNetCoreCLI@2 task. VSTest@3 and Maven@4 usage is similar.

- task: DotNetCoreCLI@2
  inputs:
    command: 'run'
    connectedServiceName: <Azure service connection configured with workload identity federation>
  env:
    SYSTEM_ACCESSTOKEN: $(System.AccessToken)

For more information on AzurePipelinesCredential, see Improve security posture in Azure service connections with AzurePipelinesCredential.

Why is my build, publish, or test step failing to restore packages?

Most dotnet commands, including build, publish, and test include an implicit restore step. This will fail against authenticated feeds, even if you ran a successful dotnet restore in an earlier step, because the earlier step will have cleaned up the credentials it used.

To fix this issue, add the --no-restore flag to the Arguments textbox.

In addition, the test command does not recognize the feedRestore or vstsFeed arguments, and feeds specified in this manner will not be included in the generated NuGet.config file when the implicit restore step runs. It's recommended that an explicit dotnet restore step be used to restore packages. The restore command respects the feedRestore and vstsFeed arguments.

Why am I getting NU1507 warnings with Package Source Mapping although when building on my machine it has no warnings?

The the various commands that do a NuGet restore or access a NuGet feed build a special temporary NuGet.config file that add NuGet authentication for azure artifacts NuGet feeds. The way this is done is in conflict with the schema that Package Source Mapping uses to map the packages to the sources and breaks the Package Source Mappin configuration in the NuGet.config file in your repository. To work around this conflict you can use the NuGet Authenticate task to authenticate and afterwards the custom command to invoke the desired dotnet command without the NuGet.config modification.

# 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'

Why should I check in a NuGet.config?

Checking a NuGet.config into source control ensures that a key piece of information needed to build your project—the location of its packages—is available to every developer that checks out your code.

However, for situations where a team of developers works on a large range of projects, it's also possible to add an Azure Artifacts feed to the global NuGet.config on each developer's machine. In these situations, using the Feeds I select here option in the NuGet task replicates this configuration.

Troubleshooting

Project using Entity Framework has stopped working on Hosted Agents

.NET Core does not have Entity Framework(EF) built-in. You will have to either install EF before beginning execution or add global.json to the project with required .NET Core SDK version. This will ensure that correct SDK is used to build EF project. If the required version is not present on the machine, add the UseDotNetV2 task to your pipeline to install the required version. For more information, see Get the Entity Framework Core runtime.

Examples

Build examples

Build a project

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

Build Multiple Projects

# 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.

Push examples

Push NuGet packages to internal feed

# 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'

Push NuGet packages to external feed

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

Pack examples

Pack a NuGetPackage to a specific output directory

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

Pack a Symbol Package

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

Publish examples

Publish projects to specified folder

# 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 examples

#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

Test examples

Run tests in your repository

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

Requirements

Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 2.144.0 or greater
Task category Build
Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 2.115.0 or greater
Task category Build
Requirement Description
Pipeline types YAML, Classic build, Classic release
Runs on Agent
Demands None
Capabilities This task does not satisfy any demands for subsequent tasks in the job.
Command restrictions Any
Settable variables Any
Agent version 2.0.0 or greater
Task category Build