web-dev-qa-db-ja.com

ビルドアーティファクトの公開が次のエラーで失敗しました:見つかりませんPathtoPublish:D:\ a \ 1 \ s \ $(buildStagingDirectory)

VSTSで.NetコアAPIのCIパイプラインを構築します。しかし、ビルド中に以下のエラーが発生します。

_Publishing build artifacts failed with an error: Not found PathtoPublish: D:\a\1\s\$(buildStagingDirectory)
_

これは私のビルド定義は次のようになります

enter image description here

PathToPublishを$(buildStagingDirectory)として言及しました

このエラーを取り除くにはどうすればよいですか?

4
Kgn-web

まったく同じエラーが発生しました。

原因

_system.debug_変数をtrueに設定した後、公開タスクが実際に出力フォルダー(デフォルトでは$(build.artifactstagingdirectory))のZipを実行し、これを1レベル上に配置することが明らかになりました。ディレクトリ構造内。次に、削除実際のフォルダー自体に進みます。これが意図されたものなのか、バグなのかはわかりません。

回避策

上記を確認した後、公開タスクの出力を$(build.artifactstagingdirectory)\artifactに書き込むだけで、結果の_Publish Artifact_タスクはまだ$(build.artifactstagingdirectory)

失敗するデフォルトの公開タスク出力

_2018-06-07T02:24:17.8506434Z ##[debug]Zip Source: D:\a\1\a
2018-06-07T02:24:17.8508216Z ##[debug]Zip arguments: Source: D:\a\1\a , target: D:\a\1\a.Zip
2018-06-07T02:24:18.0627499Z ##[debug]Successfully created archive D:\a\1\a.Zip
2018-06-07T02:24:18.0628200Z ##[debug]rm -rf D:\a\1\a
2018-06-07T02:24:18.0629858Z ##[debug]removing directory
...
...
2018-06-07T02:24:18.3052522Z ##[error]Publishing build artifacts failed with an error: Not found PathtoPublish: D:\a\1\a
_

ディレクトリを追加した後の出力を変更

_2018-06-07T02:38:59.8138062Z ##[debug]Zip Source: D:\a\1\a\artifact
2018-06-07T02:38:59.8139294Z ##[debug]Zip arguments: Source: D:\a\1\a\artifact , target: D:\a\1\a\artifact.Zip
2018-06-07T02:39:00.0331460Z ##[debug]Successfully created archive D:\a\1\a\artifact.Zip
2018-06-07T02:39:00.0334435Z ##[debug]rm -rf D:\a\1\a\artifact
2018-06-07T02:39:00.0336336Z ##[debug]removing directory
...
...
2018-06-07T02:39:00.4157615Z Uploading 1 files
2018-06-07T02:39:01.9425586Z ##[debug]File: 'D:\a\1\a\artifact.Zip' took 1504 milliseconds to finish upload
_
1
Wah Yuen

すでに指摘したように、おそらくドットで$(build.StagingDirectory)を意味しているでしょう。しかし、私は同じ問題に遭遇したので、それを単純なタイプミスと見なしています。

答えは、PUBLISHING BUILD変数が使用できないように見える場合です(ツールチップに例として示されているにもかかわらず)。おそらく必要なのは$(System.ArtifactsDirectory)です。それは私のために働いた。

0
Brian Cryer

これは私のために働いた

- task: PublishBuildArtifacts@1
  inputs:
    PathtoPublish: $(System.DefaultWorkingDirectory)/bin/Any CPU/Release/netcoreapp3.1
    ArtifactName: 'drop'
    publishLocation: 'Container'
0
Mosè Bottacini

その名前の組み込み変数はありません。お探しですか?

$(Build.ArtifactStagingDirectory)

参照: https://docs.Microsoft.com/en-us/vsts/pipelines/build/variables?view=vsts&tabs=batch

0
jessehouwing