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

Improve initialization of Language property #2604

Merged
merged 1 commit into from
Feb 24, 2021
Merged

Improve initialization of Language property #2604

merged 1 commit into from
Feb 24, 2021

Conversation

ermshiperete
Copy link
Contributor

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.

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.
@arturcic arturcic merged commit 749cbe3 into GitTools:main Feb 24, 2021
@arturcic
Copy link
Member

@ermshiperete thank you so much for your contributions 👍

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

Successfully merging this pull request may close these issues.

[Bug] GitVersion.MSBuild dotnet pack fails under Linux
2 participants