3

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.

Erik Thysell
  • 1,160
  • 1
  • 14
  • 31

1 Answers1

2

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.

Rob Bos
  • 1,320
  • 1
  • 10
  • 25
  • I thought the minimatch pattern was enough as a filename, but thanks for the explanation and tip I'll try that – Erik Thysell Feb 26 '21 at 21:26
  • It's interesting for the minimatch pattern works with other commands (such as VSBuild) and with dotnet build and project files (I.e. **/MyWebbApp.csproj) – Erik Thysell Feb 26 '21 at 22:07
  • 1
    VSBuild is a different tool with different parameters. dotnet can either compile a singel solution or multiple projects. VSBuild can handle mutliple solution files IIRC, seems that they didn't port that over. – Rob Bos Feb 27 '21 at 18:50