我的预构建脚本最初是一个 .bat。当我添加生成版本号的功能时,我在 PowerShell 中编写了它(我真的不喜欢批处理)。因此,我尝试将整个预构建脚本转换为 PowerShell,但遇到了困难。
## pre-build.ps1
function SetPackageVersion
{
if(gitversion /output json /showvariable PreReleaseTagWithDash)
{
##myget[buildNumber "$(gitversion /output json /showvariable Major).$(gitversion /output json /showvariable Minor).$(gitversion /output json /showvariable CommitsSinceVersionSource)-$(gitversion /output json /showvariable PreReleaseTagWithDash)"]
}
else
{
##myget[buildNumber "$(gitversion /output json /showvariable Major).$(gitversion /output json /showvariable Minor).$(gitversion /output json /showvariable CommitsSinceVersionSource)"]
}
GitVersion /updateassemblyinfo true
}
set config=Release
SetPackageVersion
## Package restore
NuGet restore Library\packages.config -OutputDirectory %cd%\packages -NonInteractive
Build "%programfiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" MakeMeATable.sln /p:Configuration="%config%" /m /v:M /fl /flp:LogFile=msbuild.log;Verbosity=Normal /nr:false
## Package
mkdir Build
nuget pack "Library\MakeMeATable.csproj" -symbols -o Build -p Configuration=%config% %version%
我在 MyGet 构建日志中收到这些错误(等等)
构建:术语“构建”未被识别为 cmdlet、函数的名称, 脚本文件或可运行的程序。检查名称的拼写,或者如果路径 已包含,请验证路径是否正确,然后重试。 在 D:\temp\fcd4ee1\pre-build.ps1:24 char:1 + 构建 "%programfiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" MakeMeATable ... + ~~~~~ + CategoryInfo : ObjectNotFound: (Build:String) [], CommandNotFoundException +fullyQualifiedErrorId:CommandNotFoundException 术语 'Verbosity=Normal' 未被识别为 cmdlet、函数的名称, 脚本文件或可运行的程序。检查名称的拼写,或者如果路径 已包含,请验证路径是否正确,然后重试。 在 D:\temp\fcd4ee1\pre-build.ps1:24 char:140 + ... onfig%" /m /v:M /fl /flp:LogFile=msbuild.log;Verbosity=Normal /nr:fal ... + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (Verbosity=Normal:String) [], CommandNotFoundException +fullyQualifiedErrorId:CommandNotFoundException
我不明白为什么我找不到任何关于为 MyGet 创建 PowerShell 预构建脚本的方法的好的参考资料?所有的例子都是在课堂上批量编写的!
- 有没有我错过的在线资源?
- 在 PowerShell 中,使用 MyGet 构建和打包库的正确(官方/最简单)方法是什么?