My pre-build script originally was a .bat. When I added the functionality to generate the version number, I wrote it in PowerShell (I really don't like batch). So I tried to convert the whole pre-build script into PowerShell but I'm running into difficulties.
## 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%
I get these errors in the MyGet build log (among others)
Build : The term 'Build' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At D:\temp\fcd4ee1\pre-build.ps1:24 char:1 + Build "%programfiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe" MakeMeATable ... + ~~~~~ + CategoryInfo : ObjectNotFound: (Build:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException The term 'Verbosity=Normal' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At 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
I do not understand why I can't find any good reference about the way to create a PowerShell prebuild script for MyGet? All the examples are written in class batch!
- Are there any resources online that I missed ?
- What is the proper (official/most simple) way, in PowerShell, to build and package a library with MyGet?