Skip to content

Commit 749cbe3

Browse files
ermshiperetearturcic
authored andcommitted
Improve initialization of Language property
During regular builds MSBuild initializes `Language` to the language of the currently building project, e.g. C#. However, when running some targets like `pack` this doesn't happen. Therefore GitVersion has to add a default value for `Language`. Unfortunately `Language` is also an environment variable that GNU gettext uses, so the `pack` target will fail on most Linux systems where that environment variable is set. This change implements a fix by additionally checking `DefaultLanguageSourceExtension` which gets set by MSBuild at the same time as `Language`. If that isn't set we can be pretty sure that `Language` didn't get set automatically by MSBuild and can set a default value. This will cause existing builds to break IF they rely on being able to explicitly set `Language` to a value different from C#. However, I don't think this is a scenario that happens very often, and it can be easily worked around by setting the `DefaultLanguageSourceExtension` property to a non-empty value. This fixes #2591.
1 parent fc73711 commit 749cbe3

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/GitVersion.MsBuild/msbuild/tools/GitVersion.MsBuild.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<PropertyGroup>
55
<GitVersionOutputFile>$([MSBuild]::EnsureTrailingSlash($(BaseIntermediateOutputPath)))gitversion.json</GitVersionOutputFile>
66

7-
<Language Condition=" '$(Language)' == '' ">C#</Language>
7+
<Language Condition=" '$(Language)' == '' Or '$(DefaultLanguageSourceExtension)' == ''">C#</Language>
88
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">$(MSBuildProjectDirectory)/../</SolutionDir>
99
<GitVersionPath Condition="'$(GitVersionPath)' == '' And '$(GitVersionUseSolutionDir)' == 'true'">$(SolutionDir)</GitVersionPath>
1010
<GitVersionPath Condition="'$(GitVersionPath)' == ''">$(MSBuildProjectDirectory)</GitVersionPath>

0 commit comments

Comments
 (0)