Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build fails with [ Could not inject value for "Build.GitVersion" ] but only when ran in Azure DevOps pipeline #1012

Closed
bhehe opened this issue Sep 12, 2022 · 0 comments

Comments

@bhehe
Copy link

bhehe commented Sep 12, 2022

Usage Information

Nuke 6.2.1, .NET 6, DevOps Pipeline using "windows_latest", leveraging GitVersion.CommandLine package v5.10.3

Description

Similar to the problem reported in issue #1008 I get the same error with Could not inject value for "Build.GitVersion" and in my case it's an Azure DevOps pipeline.

The repo for this solution/build follows the same approaches/layout as we use in several other repos and we're using almost identical build.cs contents and our build pipeline & gitversion yaml files are almost the same as well.

Being that this fails in injecting the tooling, I'm not seeing anything really helpful in the logged contents/stack trace.

Myself & another engineer have compared this repo to the others that work just fine and we're not seeing anything that would account for why this repo's build fails - and it only fails when ran in the DevOps pipeline.

Any tips/tricks/pointers on how to chase this further would be appreciated.

Reproduction Steps

Use the GitVersion.CommandLine package

<PackageReference Include="GitVersion.CommandLine" Version="5.10.3">
	<PrivateAssets>all</PrivateAssets>
	<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>

Include the GitVersion tooling in the Build.cs file:

[GitVersion] readonly GitVersion GitVersion;

Consume the property, causing it to lazy-load/initialize which then fails due to a null reference exception. I.e.

    var versionNumber = GitVersion.NuGetVersionV2;

Expected Behavior

GitVersion tooling should be injected and available for consuming.

Actual Behavior

NullReferenceException is throw since the GitVersion property was not injected correctly.

20:03:28 [WRN] Could not inject value for Build.GitVersion
Nuke.Common.Tooling.ProcessException: Process 'gitversion.exe' exited with code 1.

C:\Users\VssAdministrator.nuget\packages\gitversion.commandline\5.10.3\tools\gitversion.exe /nocache
@ D:\a\1\s

at Nuke.Common.Tooling.ProcessExtensions.AssertZeroExitCode(IProcess process) in //source/Nuke.Common/Tooling/ProcessExtensions.cs:line 39
at Nuke.Common.Tools.GitVersion.GitVersionTasks.GitVersion(GitVersionSettings toolSettings) in /
/source/Nuke.Common/Tools/GitVersion/GitVersion.Generated.cs:line 83
at Nuke.Common.Tools.GitVersion.GitVersionTasks.GitVersion(Configure`1 configurator) in //source/Nuke.Common/Tools/GitVersion/GitVersion.Generated.cs:line 121
at Nuke.Common.Tools.GitVersion.GitVersionAttribute.GetValue(MemberInfo member, Object instance) in /
/source/Nuke.Common/Tools/GitVersion/GitVersionAttribute.cs:line 47
at Nuke.Common.ValueInjection.ValueInjectionAttributeBase.TryGetValue(MemberInfo member, Object instance) in /_/source/Nuke.Common/ValueInjection/ValueInjectionAttributeBase.cs:line 25

Regression?

No, other repos are using the same versions of Nuke & GitVersion and work fine.

Known Workarounds

No workaround identified; Very hard to triage why the injection fails / what GitVersion is struggling with that only applies when running in the pipeline.

@bhehe bhehe added the bug 🪲 label Sep 12, 2022
@matkoch matkoch removed the bug 🪲 label Sep 12, 2022
@nuke-build nuke-build locked and limited conversation to collaborators Sep 12, 2022
@matkoch matkoch converted this issue into discussion #1013 Sep 12, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants