2

I am trying to setup CI/CD pipeline and publish process for .NET Core 2.1 sample project (it's default project that comes out of the box) using Azure DevOps. So far I have not alter the default code nor have added/removed any references in the project. It's building and running without any error locally.

I have created a simple build pipeline with tasks like Restore, Build and Publish.

For some reason, Publish fails with the following error.

##[section]Starting: Publish
==============================================================================
Task         : .NET Core
Description  : Build, test, package, or publish a dotnet application, or run a custom dotnet command. For package commands, supports NuGet.org and authenticated feeds like Package Management and MyGet.
Version      : 2.149.0
Author       : Microsoft Corporation
Help         : [More Information](https://go.microsoft.com/fwlink/?linkid=832194)
==============================================================================
[command]C:\windows\system32\chcp.com 65001
Active code page: 65001
[command]"C:\Program Files\dotnet\dotnet.exe" publish "D:\a\1\s\Devops Demo\Devops Demo.csproj" --configuration release --output D:\a\1\a\Devops Demo
Microsoft (R) Build Engine version 15.9.20+g88f5fadfbe for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.

MSBUILD : error MSB1008: Only one project can be specified.
Switch: Demo

For switch syntax, type "MSBuild /help"
##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
##[error]Dotnet command failed with non-zero exit code on the following projects : D:\a\1\s\Devops Demo\Devops Demo.csproj
##[section]Finishing: Publish

I have Googled and founded several people complaining about this error but no body has any definite solution for it.

So far I have not tried anything fancy in my project and CI/CD config. Above error is a blocker for me as I am unable to proceed with my simple devops setup.

Please let me know if you have any suggestion for me to fix this error.

My YAML is as below,

pool:
  name: Hosted VS2017
#Your build pipeline references an undefined variable named ‘Parameters.RestoreBuildProjects’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.RestoreBuildProjects’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971
#Your build pipeline references the ‘BuildConfiguration’ variable, which you’ve selected to be settable at queue time. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab, and then select the option to make it settable at queue time. See https://go.microsoft.com/fwlink/?linkid=865971

steps:
- task: DotNetCoreCLI@2
  displayName: Restore
  inputs:
    command: restore
    projects: '$(Parameters.RestoreBuildProjects)'

- task: DotNetCoreCLI@2
  displayName: Build
  inputs:
    projects: '$(Parameters.RestoreBuildProjects)'
    arguments: '--configuration $(BuildConfiguration)'

- task: DotNetCoreCLI@2
  displayName: Publish
  inputs:
    command: publish
    publishWebProjects: True
    arguments: '--configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)'
    workingDirectory: 'Devops Demo'

- task: PublishBuildArtifacts@1
  displayName: 'Publish Artifact'
  inputs:
    PathtoPublish: '$(build.artifactstagingdirectory)'
10
  • probably means your fileglob matches several proj files, make it more strict? Commented Apr 7, 2019 at 9:40
  • in your --output add " " in the folder name. Commented Apr 7, 2019 at 9:40
  • Thanks @4c74356b41, could you please elaborate little more on your suggestion. Commented Apr 7, 2019 at 9:41
  • @ShaykiAbramczyk Arguments is set as --configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory). Where do I add " "? Commented Apr 7, 2019 at 9:43
  • Ok,I just saw in the logs that the variable generated to D:\a\1\a\Devops Demo and I think because you have a space in the Devops Demo it can cause issues. in the workingDirectory value, can you vhange it "DevopsDemo"? or change the output to "$(build.artifactstagingdircetory)"? Commented Apr 7, 2019 at 9:46

1 Answer 1

5

The error is because in your --output D:\a\1\a\Devops Demo don't have " " and the value is contains space, so just fix the folder name to "D:\a\1\a\Devops Demo".

From the .yaml I can see you use the variable $(build.artifactstagingdirectory) so change it to "$(build.artifactstagingdirectory)".

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

1 Comment

hey, nice catch!

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.