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.

4
  • "because this folder contains more than one project or solution file". Commented Feb 26, 2021 at 17:23
  • @LexLi - but I have specified the solution... - see variables above. Commented Feb 26, 2021 at 18:50
  • No, you don't. **/MyWebApp.sln is not valid. Commented Feb 26, 2021 at 19:17
  • @LexLi - ok.... now I get it, thanks for the clarification. Commented Feb 26, 2021 at 21:24

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

I thought the minimatch pattern was enough as a filename, but thanks for the explanation and tip I'll try that
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)
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.