YAML 管道错误 - 无法找到 Git 自动与子文件夹合并的文件夹
YAML pipeline error - unable to find folder that Git auto-combines with subfolder
我有一个通过 Azure DevOps 使用的 Git 存储库,我向其中复制了文件夹和文件的层次结构。其中一些文件夹仅包含另一个文件夹。例如:
content
- epm
- bin (this contains files)
- xin (this contains files)
- edc
- bin (this contains files)
Git 自动执行的操作是将 edc
和 bin
文件夹合并到文件树中的 edc\bin
中。我什至尝试手动创建带有占位符文件的 edc
文件夹,然后是带有占位符文件的 bin
文件夹,然后删除 edc
下的占位符文件...这样做,它将 edc
和 bin
组合回 edc\bin
.
问题在于,当通过 YAML 管道将其构建到 NuGet 包中时,这似乎是一个问题。我使用生成 .nuspec
文件并添加要包含的内容的 powershell 脚本。这工作正常,它指定每个单独的文件夹和这些文件夹中的每个文件。所以它添加的条目之一是 ...content\edc
。但是随后在打包 .nuspec
的 NuGet 打包步骤中,它失败了,错误是找不到 ...content\edc
。仅仅因为在 repo 的文件树中,没有 ...content\edc
- 只有 ...content\edc\bin
.
有没有办法停止自动合并只包含一个文件夹的文件夹?如果没有,我可以在哪里提交 issue/request 以进行更改?
我不想尝试更改文件夹结构或添加额外的东西,因为这些文件已经在我们的各种项目中使用,我正在将其变成 Git 存储库和 NuGet 包为了更好的管理,不想破坏现有功能。
它不是合并文件夹,它只是直观地告诉你“edc”中直接没有文件。这完全是 Microsoft 的审美选择(顺便说一句,Github 也这样做)。可以用任何Git客户端检查文件系统,都正常
似乎没有任何方法可以禁用此功能。
显然我的问题是 .nuspec 文件不应该在“文件”部分包含文件夹。我添加了文件扩展名检查,如果它是空白的,请不要将其添加到列表中。
并且我设法添加设置 'target' 与在回购中的文件结构相同。这是用于创建 .nuspec 文件的 powershell 脚本,其中包括执行这两项操作,以防其他人发现这有帮助:
Param(
[string]$pkgName,
[string]$pkgVersion,
[string]$basePath,
[string]$branchForPackageName,
[string]$contentFolder
)
if($pkgVersion -match '([0-9]{1,})\.([0-9]{1,})\.([0-9]{1,})\.{0,1}([0-9]{0,})$'){
$matchedVersion = $Matches[0]
$version=$matchedVersion
$a=$version.Split(".")
$version="{0:00}" -f ([int]$a[0]) + "." + "{0:00}" -f ([int]$a[1]) + "." + "{0:00}" -f ([int]$a[2]) + "." + "{0:00}" -f ([int]$a[3])
$files=Get-ChildItem -Path $basePath$contentFolder -Recurse
Write-Host $files.Count " items in " $basePath$contentFolder
$baseName=$pkgName+".nuspec"
$nuspecFile = Join-Path $basePath $baseName
if((Test-Path $nuspecFile)){
Remove-Item $nuspecFile
}
$title = $pkgName+"."+$branchForPackageName
$description = (Get-Content -Path $basePath$contentFolder\README.md)[1]
if($description -eq ""){
$description = $title+" Support DLL"
}
Add-Content $nuspecFile "<?xml version='1.0'?>"
Add-Content $nuspecFile "<package >"
Add-Content $nuspecFile " <metadata>"
Add-Content $nuspecFile " <id>$title</id>"
Add-Content $nuspecFile " <version>$version</version>"
Add-Content $nuspecFile " <title>$title</title>"
Add-Content $nuspecFile " <authors>me</authors>"
Add-Content $nuspecFile " <owners>me</owners>"
Add-Content $nuspecFile " <requireLicenseAcceptance>false</requireLicenseAcceptance>"
Add-Content $nuspecFile " <description>$description</description>"
Add-Content $nuspecFile " <releaseNotes></releaseNotes>"
Add-Content $nuspecFile " <copyright>Copyright 2021</copyright>"
Add-Content $nuspecFile " <tags>$pkgName</tags>"
Add-Content $nuspecFile " </metadata>"
Add-Content $nuspecFile " <files>"
for($n=0; $n -lt $files.Count; $n++){
$fileName = $files[$n].FullName
if(([IO.Path]::GetExtension($fileName) -ne "")){
$fileName -match "\$contentFolder\(?<remainder>.*)"
$targetFile = $matches['remainder']
Add-Content $nuspecFile " <file src=""$fileName"" target=""content$pkgName$targetFile"" />"
}
}
Add-Content $nuspecFile " </files>"
Add-Content $nuspecFile "</package>"
}
我有一个通过 Azure DevOps 使用的 Git 存储库,我向其中复制了文件夹和文件的层次结构。其中一些文件夹仅包含另一个文件夹。例如:
content
- epm
- bin (this contains files)
- xin (this contains files)
- edc
- bin (this contains files)
Git 自动执行的操作是将 edc
和 bin
文件夹合并到文件树中的 edc\bin
中。我什至尝试手动创建带有占位符文件的 edc
文件夹,然后是带有占位符文件的 bin
文件夹,然后删除 edc
下的占位符文件...这样做,它将 edc
和 bin
组合回 edc\bin
.
问题在于,当通过 YAML 管道将其构建到 NuGet 包中时,这似乎是一个问题。我使用生成 .nuspec
文件并添加要包含的内容的 powershell 脚本。这工作正常,它指定每个单独的文件夹和这些文件夹中的每个文件。所以它添加的条目之一是 ...content\edc
。但是随后在打包 .nuspec
的 NuGet 打包步骤中,它失败了,错误是找不到 ...content\edc
。仅仅因为在 repo 的文件树中,没有 ...content\edc
- 只有 ...content\edc\bin
.
有没有办法停止自动合并只包含一个文件夹的文件夹?如果没有,我可以在哪里提交 issue/request 以进行更改?
我不想尝试更改文件夹结构或添加额外的东西,因为这些文件已经在我们的各种项目中使用,我正在将其变成 Git 存储库和 NuGet 包为了更好的管理,不想破坏现有功能。
它不是合并文件夹,它只是直观地告诉你“edc”中直接没有文件。这完全是 Microsoft 的审美选择(顺便说一句,Github 也这样做)。可以用任何Git客户端检查文件系统,都正常
似乎没有任何方法可以禁用此功能。
显然我的问题是 .nuspec 文件不应该在“文件”部分包含文件夹。我添加了文件扩展名检查,如果它是空白的,请不要将其添加到列表中。
并且我设法添加设置 'target' 与在回购中的文件结构相同。这是用于创建 .nuspec 文件的 powershell 脚本,其中包括执行这两项操作,以防其他人发现这有帮助:
Param(
[string]$pkgName,
[string]$pkgVersion,
[string]$basePath,
[string]$branchForPackageName,
[string]$contentFolder
)
if($pkgVersion -match '([0-9]{1,})\.([0-9]{1,})\.([0-9]{1,})\.{0,1}([0-9]{0,})$'){
$matchedVersion = $Matches[0]
$version=$matchedVersion
$a=$version.Split(".")
$version="{0:00}" -f ([int]$a[0]) + "." + "{0:00}" -f ([int]$a[1]) + "." + "{0:00}" -f ([int]$a[2]) + "." + "{0:00}" -f ([int]$a[3])
$files=Get-ChildItem -Path $basePath$contentFolder -Recurse
Write-Host $files.Count " items in " $basePath$contentFolder
$baseName=$pkgName+".nuspec"
$nuspecFile = Join-Path $basePath $baseName
if((Test-Path $nuspecFile)){
Remove-Item $nuspecFile
}
$title = $pkgName+"."+$branchForPackageName
$description = (Get-Content -Path $basePath$contentFolder\README.md)[1]
if($description -eq ""){
$description = $title+" Support DLL"
}
Add-Content $nuspecFile "<?xml version='1.0'?>"
Add-Content $nuspecFile "<package >"
Add-Content $nuspecFile " <metadata>"
Add-Content $nuspecFile " <id>$title</id>"
Add-Content $nuspecFile " <version>$version</version>"
Add-Content $nuspecFile " <title>$title</title>"
Add-Content $nuspecFile " <authors>me</authors>"
Add-Content $nuspecFile " <owners>me</owners>"
Add-Content $nuspecFile " <requireLicenseAcceptance>false</requireLicenseAcceptance>"
Add-Content $nuspecFile " <description>$description</description>"
Add-Content $nuspecFile " <releaseNotes></releaseNotes>"
Add-Content $nuspecFile " <copyright>Copyright 2021</copyright>"
Add-Content $nuspecFile " <tags>$pkgName</tags>"
Add-Content $nuspecFile " </metadata>"
Add-Content $nuspecFile " <files>"
for($n=0; $n -lt $files.Count; $n++){
$fileName = $files[$n].FullName
if(([IO.Path]::GetExtension($fileName) -ne "")){
$fileName -match "\$contentFolder\(?<remainder>.*)"
$targetFile = $matches['remainder']
Add-Content $nuspecFile " <file src=""$fileName"" target=""content$pkgName$targetFile"" />"
}
}
Add-Content $nuspecFile " </files>"
Add-Content $nuspecFile "</package>"
}