Skip to content
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

[Bug] Azure DevOps UseGitVersion@5 task and GitVersion 5.2.4 produces an error "AssemblyInfoFilename file not found at null" when UpdateAssemblyInfo: true is set #2225

Closed
dsbut opened this issue Apr 6, 2020 · 23 comments · Fixed by #2240
Assignees
Labels
Milestone

Comments

@dsbut
Copy link

dsbut commented Apr 6, 2020

Describe the bug
I have recently been updating pipelines to use the UseGitVersion@5 task, replacing the obsolete GitVersion@5 task. For the most part, this has been easy, and I did not encounter any problems until I switched out the task on a pipeline which use GitVersion to update the AssemblyInfo.cs files for a .Net Framework solution. When run, the build fails on the UseGitVersion@5 task, with the error message:

##[error]Error: AssemblyInfoFilename file not found at null

The task is defined in my pipeline as per the example in the GitVersion docs:

- task: UseGitVersion@5
  inputs:
    versionSpec: '5.x'
    updateAssemblyInfo: true

Expected Behavior

The UseGitVersion@5 task should update all AssemblyInfo.cs files under the repository

Actual Behavior

Task execution fails with the error AssemblyInfoFilename file not found at null.

Possible Fix

Unfortunately, I have nothing concrete to offer beyond wild speculation.

Steps to Reproduce

This may be reproduced using the simple pipeline below, in a repo containing a .Net Framework solution with projects that include AssemblyInfo.cs files.
Gitversion.yml file also attached.

See the attached log from pipeline task execution
UserGitVersionPipelineTaskLog.log
with debugging enabled

Context

No longer able to automate the versioning of assemblies with UseGitVersion@5 as ws possible with GitVersion@5 task.

Your Environment

Azure DevOps Pipelines running on MS hosted Windows Agent

  • Version Used:
  • windows-latest MS hosted agent
  • UseGitVersion@5 - v5.1.2
  • GitVersion 5.2.4

Sample Pipeline

pool:
  vmImage: 'windows-latest'

steps:
- task: UseGitVersion@5
  inputs:
    versionSpec: '5.x'
    updateAssemblyInfo: true

Sample GitVersion.yml config used...nothing to see here really

branches: {}
ignore:
  sha: []
merge-message-formats: {}
@dsbut dsbut added the bug label Apr 6, 2020
@suddenelfilio
Copy link

We are currently experiencing the same issue. No solution found yet.

@arturcic arturcic self-assigned this Apr 8, 2020
@salaerts
Copy link

salaerts commented Apr 8, 2020

We have encountered the same issue today.

Pipeline YAML

trigger:
- master
- feature/*

pool:
  vmImage: 'windows-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'
  GitVersion.SemVer: ''
  DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
  DOTNET_CLI_TELEMETRY_OPTOUT: true

steps:
- task: NuGetToolInstaller@1

- task: NuGetCommand@2
  inputs:
    restoreSolution: '$(solution)'

- task: UseGitVersion@5
  displayName: gitversion
  inputs: 
    versionSpec: '5.x'
    updateAssemblyInfo: true

Gitversion YAML config

mode: ContinuousDeployment
next-version: 1.0
assembly-versioning-scheme: MajorMinorPatch
assembly-file-versioning-scheme: MajorMinorPatchTag
assembly-informational-format: '{InformationalVersion}'
increment: Inherit
continuous-delivery-fallback-tag: ci
tag-prefix: '[vV]'
major-version-bump-message: '\+semver:\s?(breaking|major)'
minor-version-bump-message: '\+semver:\s?(feature|minor)'
patch-version-bump-message: '\+semver:\s?(fix|patch)'
no-bump-message: '\+semver:\s?(none|skip)'
legacy-semver-padding: 4
build-metadata-padding: 4
commits-since-version-source-padding: 4
commit-message-incrementing: Enabled
commit-date-format: 'yyyy-MM-dd'
merge-message-formats: {}

@salaerts
Copy link

salaerts commented Apr 8, 2020

If I specify the full path to the assembly info file

- task: UseGitVersion@5
  displayName: gitversion
  inputs: 
    versionSpec: '5.x'
    updateAssemblyInfo: true
    updateAssemblyInfoFilename: 'src/Project/Properties/AssemblyInfo.cs'

We get a slightly different error:

##[error]Error: AssemblyInfoFilename file not found at src/Project/Properties/AssemblyInfo.cs

The path to the assembly file is correct so that is not the issue.

@salaerts
Copy link

salaerts commented Apr 8, 2020

So, apparently using the full absolute path to the AssemblyInfo.cs file seems to work:

- task: UseGitVersion@5
  displayName: gitversion
  inputs: 
    versionSpec: '5.x'
    updateAssemblyInfo: true
    updateAssemblyInfoFilename: '$(Build.SourcesDirectory)/src/Project/Properties/AssemblyInfo.cs'

Using a shared GlobalAssemblyInfo.cs file combined with this configuration might be a suitable workaround. But I would expect something like this to work just fine:

- task: UseGitVersion@5
  displayName: gitversion
  inputs: 
    versionSpec: '5.x'
    updateAssemblyInfo: true
    updateAssemblyInfoFilename: '**/AssemblyInfo.cs'

And perhaps this could even be the default convention?

The only remaining issue at this point is that we now get this warning:

Warning : File contains assembly version attributes which conflict with the attributes generated by GitVersion Properties\AssemblyInfo.cs

Which seems weird, because we don't have any version-related properties in the assembly info file:

using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Project")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Company NV")]
[assembly: AssemblyProduct("Product")]
[assembly: AssemblyCopyright("Copyright ©  2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components.  If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("10aa69b4-2816-44a2-8097-1385fcb369c7")]

@dsbut
Copy link
Author

dsbut commented Apr 8, 2020

So, apparently using the full absolute path to the AssemblyInfo.cs file seems to work:

Sadly, I have multiple AssemblyInfo.cs files to update during a build.

But I would expect something like this to work just fine:

- task: UseGitVersion@5
  displayName: gitversion
  inputs: 
    versionSpec: '5.x'
    updateAssemblyInfo: true
    updateAssemblyInfoFilename: '**/AssemblyInfo.cs' 

As would I, but it does not. It was also unnecessary to be explicit about AssemblyInfo.cs file paths in the obsolete GitVersion@5 task. The simplicity of configuration/inputs in the original GitVersion@5 task was a big driver behind why we adopted it in our organization. The UseGitVersion@5 is even better with seemingly even less to express to get it to "do the right thiing" - I don't believe it was the intent that the behavior of simply setting updateAssemblyInfo: true was meant to break or even change in the UseGitVersion@5 task.

While I appreciate the sentiments and suggestions expressed above, an AssemblyInfo.cs shared across projects is unfortunately not a viable workaround in my particular situation (impacts too many projects).

Also, since a file pattern such as updateAssemblyInfoFilename: '$(Build.SourcesDirectory)/**/AssemblyInfo.cs also does not work, then there has clearly been a regression as compared to the, now deprecated, GitVersion@5 task. The UseGitVersion@5 task appears to be completely incapable of updating multiple AssemblyInfo.cs files, which does not align with either the documented behavior or, as already mentioned, implicit behavior in GitVersion@5.

As an aside, I've also noticed a comparatively large performance degradation in UseGitVersion@5 vs GitVersion@5. It seems on average UseGitVersion@5 runs roughly 6-7 times slower at around 30-35 seconds, versus GitVersion@5 which runs in roughly 5-6 seconds on the same agent and repository. This is not a deal-breaker by any means, merely an observation for the feedback bucket.

@arturcic arturcic added this to the 5.3.0 milestone Apr 18, 2020
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 22, 2020
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 23, 2020
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 23, 2020
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 29, 2020
arturcic added a commit to arturcic/GitVersion that referenced this issue Apr 30, 2020
@dsbut
Copy link
Author

dsbut commented May 3, 2020

Hi @arturcic

Now that this issue is closed, do we simply need to wait for the 5.3.0 release of GitVersion in order for the UseGitVersion@5 task to work when defined as below? Or, is there more to it than that?

- task: UseGitVersion@5
  inputs:
    versionSpec: '5.x'
    updateAssemblyInfo: true

@arturcic
Copy link
Member

arturcic commented May 3, 2020

Kind of yes, but I test with the GitTools extension not UseGitversion. As we're moving to the GitTools extension, the UseGitversion will be obsolete

@github-actions
Copy link

github-actions bot commented May 4, 2020

🎉 This issue has been resolved in version 5.3.0 🎉
The release is available on:

Your GitReleaseManager bot 📦🚀

@svengeance
Copy link
Contributor

svengeance commented May 6, 2020

@arturcic Was the File Globbing implemented this version? I just tried the UseGitVersion task with 5.3.2, checking Update AssemblyInfo, and specifying **/AssemblyInfo.cs. I got an error stating that no such file was found.

However
If I add /updateassemblyinfo /diag to the command line arguments parameter, it actually works as intended, indicating it updated the files correctly in the diagnostics output.

@maurert
Copy link

maurert commented May 7, 2020

I can't seem to get it to work

  • task: UseGitVersion@5
    displayName: gitversion
    inputs:
    versionSpec: '5.3.2'
    includePrerelease: true
    updateAssemblyInfo: true

##[error]Error: AssemblyInfoFilename file not found at null

@arturcic
Copy link
Member

arturcic commented May 7, 2020

Use GitTools instead of UseGitversion

@maurert
Copy link

maurert commented May 7, 2020

With GitTools I get
Starting: gitversionexecute

Task : Execute GitVersion Task
Description : Easy Semantic Versioning (http://semver.org) for projects using Git
Version : 0.9.3
Author : GitTools Contributors
Help : See the documentation for help

##[error]Error: AssemblyInfoFilename file not found at undefined
Finishing: gitversionexecute

@arturcic
Copy link
Member

arturcic commented May 7, 2020

That is weird, do you have any assembly info?

@arturcic
Copy link
Member

arturcic commented May 7, 2020

Looks like it cannot find one

@maurert
Copy link

maurert commented May 7, 2020

Yes its in the Properties folder of the project

@arturcic
Copy link
Member

arturcic commented May 7, 2020

Is it public project?

@maurert
Copy link

maurert commented May 7, 2020

Its a private project .. I can share it using email?

@arturcic
Copy link
Member

arturcic commented May 7, 2020

Works for me

@robmarsd
Copy link

I'm also having the same issue with GitTools on Azure DevOps.

Starting: gitversionexecute
==============================================================================
Task         : Execute GitVersion Task
Description  : Easy Semantic Versioning (http://semver.org) for projects using Git
Version      : 0.9.3
Author       : GitTools Contributors
Help         : See the [documentation](https://gitversion.net/docs/) for help
==============================================================================
##[error]Error: AssemblyInfoFilename file not found at **/AssemblyInfo.cs
Finishing: gitversionexecute

Extract from the build YAML:

- task: gitversion/execute@0
  inputs:
    useConfigFile: true
    configFilePath: 'GitVersion.yml'
    updateAssemblyInfo: true
    updateAssemblyInfoFilename: '**/AssemblyInfo.cs'

I've also tried without specifying the AssemblyInfo Filename:

Starting: gitversionexecute
==============================================================================
Task         : Execute GitVersion Task
Description  : Easy Semantic Versioning (http://semver.org) for projects using Git
Version      : 0.9.3
Author       : GitTools Contributors
Help         : See the [documentation](https://gitversion.net/docs/) for help
==============================================================================
##[error]Error: AssemblyInfoFilename file not found at undefined
Finishing: gitversionexecute

Build task:

- task: gitversion/execute@0
  inputs:
    useConfigFile: true
    configFilePath: 'GitVersion.yml'
    updateAssemblyInfo: true

@mrbiggred
Copy link

I got a similar issue and opened an issue in the GitVersion Actions repo.

@iamNoah1
Copy link

I encountered this bug in Version 5.3.x, should I create a new Issue?

@greengumby
Copy link

Has this been corrected yet?

@asbjornu
Copy link
Member

asbjornu commented Feb 5, 2021

GitTools/actions#316 should fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.