Vince
Vince

Reputation: 1406

Azure/DevOps with Github Repo - Path to the Project to build

I'm trying to create a CI/CD pipeline for a Project on Github with the help of VSTS (Azure DevOps) to Azure WebApp.

I'm at the beggining of the process and i'm stuck at getting my project to be build in VSTS directly.

The backend project is a DotNetCore project and the front-end is not determined yet.

My repository on github will look like something like this

/
 -> Project.FrondEnd
 -> Project.BackEnd
 -> Documents
 -> .gitignore
 -> readme.md

In the folder Project.BackEnd it will look like:

/Project.BackEnd
 -> Project.Api (Entry point of the server app)
 -> Project.Entities
 -> Project.DataAccess
 -> Project.Services
 -> Project.sln

When i configure the Pipeline on VSTS, i need to write the pipeline.yml file but it seems i'm missing some knowledge to how to point to my server entry point so it can build the project!

This is my yml file

trigger:
- master

pool:
  vmImage: 'vs2017-win2016'

variables:
  buildConfiguration: 'Release'

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

That way it doesn't work and i get this message:

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

i've tried to change the steps to something like this

steps:
- script: dir
  workingDirectory: $(Agent.BuildDirectory)
  displayName: List contents of a folder

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

but i get those directory where i am:

/
 -> a
 -> b
 -> s
 -> TestResult

I'm a bit lost...

So how can i get the source from my github under the Project.BackEnd and make it build so i can continue to the next step!?

Upvotes: 2

Views: 4240

Answers (1)

baywet
baywet

Reputation: 5302

You can specify the path to your project or solution between the "build" and the --configuration. Setting it up to something like this should solve your problem:

$(Build.SourcesDirectory)/path/toCSProjOrSln.sln

$(Build.SourcesDirectory) will directly be replaced by whateverbefore/s so you know you're at the root of your repo. More information on pre-defined variables and on the dotnet core cli

Upvotes: 6

Related Questions