Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify Solution file in Azure DevOps Pipeline

Tags:

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.

like image 626
JLo Avatar asked Sep 17 '18 09:09

JLo


People also ask

How do I edit Azure DevOps pipeline YAML?

Edit a YAML pipelineSign in to your organization ( https://dev.azure.com/{yourorganization} ). Select your project, choose Pipelines > Pipelines, and then select the pipeline you want to edit. Choose Edit. Make edits to your pipeline using Intellisense keyboard shortcuts and the task assistant for guidance.


1 Answers

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'
like image 132
Shayki Abramczyk Avatar answered Sep 28 '22 07:09

Shayki Abramczyk