23

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://learn.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.

1 Answer 1

24

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'
1
  • 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, 2018 at 9:51

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.