【发布时间】:2019-04-07 09:36:05
【问题描述】:
我正在尝试使用 Azure DevOps 为 .NET Core 2.1 示例项目(即开箱即用的默认项目)设置 CI/CD 管道和发布流程。到目前为止,我还没有更改默认代码,也没有在项目中添加/删除任何引用。它正在本地构建和运行,没有任何错误。
我创建了一个简单的构建管道,其中包含还原、构建和发布等任务。
由于某种原因,发布失败并出现以下错误。
##[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 配置中尝试过任何花哨的东西。上述错误对我来说是一个障碍,因为我无法继续进行简单的 devops 设置。
如果您对我修复此错误有任何建议,请告诉我。
我的 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)'
【问题讨论】:
-
可能意味着你的fileglob匹配了几个proj文件,让它更严格?
-
在您的
--output文件夹名称中添加" "。 -
谢谢@4c74356b41,您能否详细说明您的建议。
-
@ShaykiAbramczyk 参数设置为 --configuration $(BuildConfiguration) --output $(build.artifactstagingdirectory)。我在哪里添加“”?
-
好的,我刚刚在日志中看到生成到
D:\a\1\a\Devops Demo的变量,我认为因为Devops Demo中有一个空格,它可能会导致问题。在workingDirectory值中,您可以将其更改为“DevopsDemo”吗?或将输出更改为"$(build.artifactstagingdircetory)"?
标签: azure-devops azure-pipelines