为什么我的 VSTS "Publish Artifact" 任务没有选取我发布的文件夹?

Why isn't my VSTS "Publish Artifact" task picking up my published folder?

我有一个 .NET Core 2 class 库,我正在尝试在 VSTS 中创建工件(用于 NuGet 发布,但那是下一个..)

我的 "Publish Build Artifacts" 任务找不到我通过 dotnet publish 发布的文件夹。

dotnet publish 输出:

2018-03-21T06:11:41.2709655Z [command]"C:\Program Files\dotnet\dotnet.exe" publish D:\a\s\src\xxx\xxx.csproj --configuration release --output D:\a\a\publish
2018-03-21T06:11:41.5475294Z Microsoft (R) Build Engine version 15.6.82.30579 for .NET Core
2018-03-21T06:11:41.5476483Z Copyright (C) Microsoft Corporation. All rights reserved.
2018-03-21T06:11:41.5477091Z 
2018-03-21T06:11:42.5040403Z   Restore completed in 83.05 ms for D:\a\s\src\xxx\xxx.csproj.
2018-03-21T06:11:43.3434895Z   xxx-> D:\a\s\src\xxx\bin\release\netstandard2.0\xxx.dll
2018-03-21T06:11:43.9833363Z   xxx-> D:\a\a\publish\

"Publish Build Artifacts" 任务只是出错并说:

2018-03-21T06:11:44.9159833Z ##[error]Publishing build artifacts failed with an error: Not found PathtoPublish: D:\a\a\publish
2018-03-21T06:11:44.9209300Z ##[section]Finishing: Publish Artifact

即使 dotnet publish 输出中的最后一行与该行匹配。

这是我在 VSTS 中的内容:

我做错了什么?

如果您的项目不是 asp.net 应用程序,在构建之后和 "publish artifacts" 之前,您必须添加一个复制任务,就像这样...

既然你想使用artifact进行NuGet发布,你应该使用Dotnet pack打包项目,然后发布到artifact,之后你就可以将包推送到服务器了。

  1. 删除 .NET Core 发布任务
  2. 在 Publish Build Artifacts 任务之前添加 .NET Core 任务(命令:pack)