18

I am having trouble configuring an Azure DevOps Dotnet core build process.

I have a simple dotnet core project which I am attempting to build in an Azure DevOps environment.

The project is in a subfolder within my repo, but I cannot figure out how to specify how the Pipeline should find my csproj file. The MSDN documentation suggests that you can specify it but there are no examples and all of my attempts are met with errors.

When building a pipeline with the standard dotnet CLI template, the YAML created is:

# ASP.NET Core
# Build and test ASP.NET Core web applications targeting .NET Core.
# Add steps that run tests, create a NuGet package, deploy, and more:
# https://docs.microsoft.com/vsts/pipelines/languages/dotnet-core

pool:
  vmImage: 'Ubuntu 16.04'

variables:
  buildConfiguration: 'Release'

steps:
- script: dotnet build --configuration $(buildConfiguration)
  displayName: 'dotnet build $(buildConfiguration)'

However this is met with the error:

MSBUILD : error MSB1003: Specify a project or solution file. 
The current working directory does not contain a project or solution file.

The documentation linked above suggests using a "task" based syntax rather than a script, and I assume that in the documentation the inputs are listed in the same order as the examples listed underneath.

riQQ
  • 4,188
  • 4
  • 19
  • 33
JLo
  • 2,919
  • 2
  • 16
  • 32

1 Answers1

20

If you use the script you specify the csproj file after the build word:

- script: dotnet build myrepo/test/test.csproj --configuration $(buildConfiguration)

The best way to use Azure DevOps Pipeline is to use tasks for the build pipeline, in the Dotnet Core yaml build task you specify the file in the inputs section:

- task: DotNetCoreCLI@2
  inputs:
    command: 'build' 
    projects: 'myrepo/test/test.csproj'
Shayki Abramczyk
  • 24,285
  • 13
  • 49
  • 65
  • 4
    Thanks! I thought Tasks looked like a better option, yet the built in Designer for pipelines on Azure Devops creates a YAML using the dotnet build script for some reason. With your example I've successfully created a build task using the DotnetCoreCLI task. – JLo Sep 17 '18 at 09:51