所以我试图在 tfs 构建后直接执行 ps 脚本。当脚本在构建后运行时,会出现一个错误,指出源文件必须具有有效的 .dacpac 扩展名。下面是代码
#Powershell script to capture the latest version of the dacpac generated for the source file
$srcdir= get-childitem '\\a\b\c\d\e\f' | Where {$_.LastWriteTime} | select -last 1
$srcpathitem= Join-Path \\a\b\c\d\e\f$srcdir
$filesource= get-childitem -path $srcpathitem -filter abc.dacpac
$finalsource= Join-Path $srcpathitem $filesource
#Latest version of the target file dacpac created
$tgtdir= get-childitem '\\1\2\3\4\5\6' | Where {$_.LastWriteTime} | select -last 1
$tgtpathitem= Join-Path \\1\2\3\4\5\6 $tgtdir
$filetarget= get-childitem -path $tgtpathitem -filter EFT.dacpac
$finaltarget= Join-Path $tgtpathitem $filesource
&"\\xyz\build\xyz\xyz\Scripts\DAC\bin\SqlPackage.exe" /a:Script `
/Sourcefile:$finalsource `
/TargetFile:$finaltarget `
/op:"\\xyz\build\xyz\xyz\Scripts\123-script.sql" `
抱歉,由于隐私问题,文件位置和文件夹名称已被赋予别名。
所以倒数第三个是 dacpac 出现错误的地方。所以请告诉如何传递文件路径,以免出现任何错误。并且仅供参考,路径不能被硬编码,因为文件夹在几个小时后自动创建了较新的版本。