azureazure-pipelinesazure-pipelines-build-taskazure-pipelines-yamldotnetcorecli

Can DotNetCoreCLI build solution?


I have tried in my azure build pipeline to set a DotNetCoreCLI build task to build a solution but I just get an error:

MSBUILD : error MSB1011: Specify which project or solution file to use because this folder contains more than one project or solution file. ##[error]Error: The process 'D:\WorkLib\DkDep372\Default_Win2019\1_tool\dotnet\dotnet.exe' failed with exit code 1

even though I specify solution like this:

variables:
  solution: '**/MyWebApp.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: DotNetCoreCLI@2
  displayName: 'dotnet build'
  inputs:
    command: 'build'
    solution: '$(solution)'
    configuration: $(buildConfiguration)

So my question is if DotNetCoreCLI can build a solution of it just can build projects?

This page indicates that it can. This page says something about projects but not about solutions. I havn't been able to find a single example with a build with a specified solution.


Solution

  • dotnet build either expects either a projectfile, a solution file or nothing. When you give it no additional parameter then it will search the current directory for a project or solution file.

    When you give it a file, you need to give the path to the file. In this case, you are giving it a minimatch pattern (**) to find the file, which doesn't work.

    Try to run it in the correct directory or specify the full path to the file.