如何使用Azure DevOps发布?

问题描述 投票:1回答:1

我正在尝试使用Azure DevOps为.NET Core 2.1示例项目(它是开箱即用的默认项目)设置CI / CD管道和发布过程。到目前为止,我没有更改默认代码,也没有添加/删除项目中的任何引用。它在本地构建和运行时没有任何错误。

我创建了一个简单的构建管道,其中包含Restore,Build和Publish等任务。

出于某种原因,发布失败,出现以下错误。

##[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

我用谷歌搜索并建立了几个人抱怨这个错误,但没有任何机构有任何明确的解决方案。

到目前为止,我没有在我的项目和CI / CD配置中尝试任何花哨的东西。以上错误对我来说是一个阻止,因为我无法继续我的简单设置。

如果您有任何建议让我解决此错误,请与我们联系。

我的YAML如下,

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)'
azure-devops azure-pipelines
1个回答
2
投票

错误是因为在你的--output D:\a\1\a\Devops Demo没有" "并且值包含空格,所以只需将文件夹名称修复为"D:\a\1\a\Devops Demo"

.yaml我可以看到你使用变量$(build.artifactstagingdirectory)所以将它改为"$(build.artifactstagingdirectory)"

© www.soinside.com 2019 - 2024. All rights reserved.