首页 > 解决方案 > 无法读取文件内容

问题描述

我正在尝试读取文件的内容:

$releaseNotesPath = "$(System.DefaultWorkingDirectory)\_ccp-develop\ccp\ccp\ReleaseNotes\ReleaseNotes\"
$latestReleaseNotesFile = Get-ChildItem -Path $releaseNotesPath -Filter *.txt | Select-Object FullName,Name | Sort-Object -Property Name | Select-Object -First 1

问题出现在这里:

$releaseNote = Get-Content $latestReleaseNotesFile


2021-11-14T14:29:07.0729088Z ##[error]Cannot find drive. A drive with the name '@{FullName=D' does not exist.
2021-11-14T14:29:07.1945879Z ##[error]PowerShell exited with code '1'.

我究竟做错了什么?

标签: powershellazure-devopsazure-pipelines

解决方案


您需要提供文件路径 ( FullName):

$releaseNote = Get-Content $latestReleaseNotesFile.FullName

推荐阅读