Improve initialization of Language property #2604
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
During regular builds MSBuild initializes
Language
to the language of the currently building project, e.g. C#. However, whenrunning some targets like
pack
this doesn't happen. Therefore GitVersion has to add a default value forLanguage
. UnfortunatelyLanguage
is also an environment variable that GNU gettext uses, so thepack
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 thesame time as
Language
. If that isn't set we can be pretty sure thatLanguage
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 theDefaultLanguageSourceExtension
property to a non-empty value.This fixes #2591.