Skip to content

ThisAssembly.Git exception when project has Git submodule #303

Closed
@TibbsTerry

Description

@TibbsTerry

Describe the Bug

ThisAssembly.Git produces a build error when solution has Git submodules

ThisAssembly.Git.targets(71,7): error MSB4184: The expression "[System.IO.File]::ReadAllText(/path/;/path/anotherpath/.git/HEAD)" cannot be evaluated. Could not find a part of the path '/path/;/path/anotherpath/.git/HEAD'

Issue is in ThisAssembly.Git.targets line 71 $([System.IO.File]::ReadAllText

<PropertyGroup Condition="'$(RepositoryBranch)' == '' and '$(RepositoryRoot)' != ''">
  <!-- We may not be in CI at all. If we got a git repo root, we can directly read HEAD -->
  <RepositoryHead>$(RepositoryRoot).git/HEAD</RepositoryHead>
  <RepositoryBranch Condition="Exists($(RepositoryHead))">$([System.IO.File]::ReadAllText($(RepositoryHead)).Trim())</RepositoryBranch>
  <RepositoryBranch Condition="$(RepositoryBranch) != ''">$(RepositoryBranch.TrimStart("ref:").Trim().TrimStart("refs").Trim("/").TrimStart("heads").Trim("/").Trim())</RepositoryBranch>
</PropertyGroup>

I believe because @(SourceRoot) will also return submodule information

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomershelp wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions