lholman / OneBuild

Convention based PowerShell build for .NET http://lholman.github.io/OneBuild/
Apache License 2.0
17 stars 2 forks source link

Set-BuildNumberWithGitCommitDetail fails when git is not present or repo not initiated #13

Closed lholman closed 9 years ago

lholman commented 9 years ago

Originally from @mani0070:

mani0070 commented 6 days ago WARNING: Setting [minor] version number to: 1. Build FAILED. 5 tasks, 3 errors, 3 warnings 00:00:00.8281157 Set-BuildNumberWithGitCommitDetail : You cannot call a method on a null-valued expression. At C:\Users\mani_000\Documents\Visual Studio 2013\Projects\AzureCloudService1\OneBuild.build.ps1:103 char:41

... alVersion = Set-BuildNumberWithGitCommitDetail -major $major -minor $ ...

CategoryInfo : InvalidOperation: (:) [Set-BuildNumberWithGitCom mitDetail], RuntimeException
FullyQualifiedErrorId : InvokeMethodOnNull,Set-BuildNumberWithGitCommitD etail
##teamcity[buildStatus status='FAILURE' text='{build.status.text} in execution']
lholman commented 9 years ago

Ahhh, I think this is an edge case when you have no git repo in the directory, can you try this?

c:\[path-to-solution]\>git init
c:\[path-to-solution]\>Build.bat

If that still doesn't work then try making a new commit locally, i.e.

c:\[path-to-solution]\>git add --all
c:\[path-to-solution]\>git commit -am "Initial commit"
c:\[path-to-solution]\>Build.bat

Could you let me know if either work, I'll put a test in around the Set-BuildNumberWithGitCommitDetail.psm1 module to check for a git repo first and give a better Error if it turns out to be the above.

lholman commented 9 years ago

From @mani0070:

This second option works for me.

lholman commented 9 years ago

Satisfied with PR #15