我正在尝试使用Azure DevOps设置CI / CD管道并为.NET Core 2.1示例项目(即装即用的默认项目)发布过程。到目前为止,我还没有更改默认代码,也没有添加/删除项目中的任何引用。它正在构建和运行,本地无任何错误。
我创建了一个简单的构建管道,其中包含诸如“还原”,“构建”和“发布”之类的任务。
由于某些原因,发布失败并出现以下错误。
##[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
我已经Google搜索并成立了几个抱怨此错误的人,但是没有任何机构对此有明确的解决方案。
到目前为止,我还没有在项目和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)'
答案 0 :(得分:2)
错误是因为您的--output D:\a\1\a\Devops Demo
中没有" "
,并且该值包含空格,因此只需将文件夹名称固定为"D:\a\1\a\Devops Demo"
。
从.yaml
中可以看到您使用了变量$(build.artifactstagingdirectory)
,因此将其更改为"$(build.artifactstagingdirectory)"
。