|
| 1 | +<Project> |
| 2 | + |
| 3 | + <PropertyGroup Condition="'$(RepositoryBranch)' == ''"> |
| 4 | + <!-- GitHub Actions: https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables --> |
| 5 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(GITHUB_REF)' != '' and $(GITHUB_REF.Contains('refs/pull/'))">pr$(GITHUB_REF.Replace('refs/pull/', '').Replace('/merge', ''))</RepositoryBranch> |
| 6 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(GITHUB_REF)' != ''">$(GITHUB_REF.Replace('refs/heads/', '').Replace('refs/tags/', ''))</RepositoryBranch> |
| 7 | + <!-- Azure DevOps: https://docs.microsoft.com/en-us/azure/devops/pipelines/build/variables --> |
| 8 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(BUILD_SOURCEBRANCH)' != ''">$(BUILD_SOURCEBRANCH.Replace('refs/heads/', '').Replace('refs/tags/', ''))</RepositoryBranch> |
| 9 | + <!-- AppVeyor: https://www.appveyor.com/docs/environment-variables/ --> |
| 10 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(APPVEYOR_PULL_REQUEST_NUMBER)' != ''">pr$(APPVEYOR_PULL_REQUEST_NUMBER)</RepositoryBranch> |
| 11 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(APPVEYOR_REPO_TAG_NAME)' != ''">$(APPVEYOR_REPO_TAG_NAME)</RepositoryBranch> |
| 12 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(APPVEYOR_REPO_BRANCH)' != ''">$(APPVEYOR_REPO_BRANCH)</RepositoryBranch> |
| 13 | + <!-- TeamCity: https://www.jetbrains.com/help/teamcity/predefined-build-parameters.html#Branch-Related+Parameters --> |
| 14 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(TEAMCITY_BUILD_BRANCH)' != ''">$(TEAMCITY_BUILD_BRANCH)</RepositoryBranch> |
| 15 | + <!--TravisCI: https://docs.travis-ci.com/user/environment-variables/ --> |
| 16 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(TRAVIS_PULL_REQUEST)' != '' and '$(TRAVIS_PULL_REQUEST)' != 'false'">pr$(TRAVIS_PULL_REQUEST)</RepositoryBranch> |
| 17 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(TRAVIS_BRANCH)' != ''">$(TRAVIS_BRANCH)</RepositoryBranch> |
| 18 | + <!-- CircleCI: https://circleci.com/docs/2.0/env-vars/ --> |
| 19 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(CIRCLE_PR_NUMBER)' != ''">pr$(CIRCLE_PR_NUMBER)</RepositoryBranch> |
| 20 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(CIRCLE_TAG)' != ''">$(CIRCLE_TAG)</RepositoryBranch> |
| 21 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(CIRCLE_BRANCH)' != ''">$(CIRCLE_BRANCH)</RepositoryBranch> |
| 22 | + <!-- GitLab: https://docs.gitlab.com/ee/ci/variables/predefined_variables.html --> |
| 23 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(CI_COMMIT_TAG)' != ''">$(CI_COMMIT_TAG)</RepositoryBranch> |
| 24 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(CI_MERGE_REQUEST_IID)' != ''">pr$(CI_MERGE_REQUEST_IID)</RepositoryBranch> |
| 25 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(CI_EXTERNAL_PULL_REQUEST_IID)' != ''">pr$(CI_EXTERNAL_PULL_REQUEST_IID)</RepositoryBranch> |
| 26 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(CI_COMMIT_BRANCH)' != ''">$(CI_COMMIT_BRANCH)</RepositoryBranch> |
| 27 | + <!-- Buddy: https://buddy.works/docs/pipelines/environment-variables#default-environment-variables --> |
| 28 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(BUDDY_EXECUTION_PULL_REQUEST_NO)' != ''">pr$(BUDDY_EXECUTION_PULL_REQUEST_NO)</RepositoryBranch> |
| 29 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(BUDDY_EXECUTION_TAG)' != ''">$(BUDDY_EXECUTION_TAG)</RepositoryBranch> |
| 30 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(BUDDY_EXECUTION_BRANCH)' != ''">$(BUDDY_EXECUTION_BRANCH)</RepositoryBranch> |
| 31 | + <!-- Jenkins: https://plugins.jenkins.io/git/#plugin-content-environment-variables --> |
| 32 | + <RepositoryBranch Condition="'$(RepositoryBranch)' == '' and '$(GIT_LOCAL_BRANCH)' != ''">$(GIT_LOCAL_BRANCH)</RepositoryBranch> |
| 33 | + </PropertyGroup> |
| 34 | + |
| 35 | + <!-- Make sure git info is available before calling source generators --> |
| 36 | + <Target Name="InitializeGitInformation" |
| 37 | + BeforeTargets="GenerateMSBuildEditorConfigFileShouldRun" |
| 38 | + DependsOnTargets="InitializeSourceControlInformation"> |
| 39 | + |
| 40 | + <PropertyGroup Condition="'$(SourceControlInformationFeatureSupported)' == 'true'"> |
| 41 | + <!-- The project must specify PublishRepositoryUrl=true in order to publish the URL, in order to prevent inadvertent leak of internal URL. --> |
| 42 | + <RepositoryUrl Condition="'$(RepositoryUrl)' == '' and '$(PublishRepositoryUrl)' == 'true'">$(PrivateRepositoryUrl)</RepositoryUrl> |
| 43 | + </PropertyGroup> |
| 44 | + |
| 45 | + <PropertyGroup Condition="'$(SourceRevisionId)' != ''"> |
| 46 | + <RepositoryCommit Condition="'$(RepositoryCommit)' == ''">$(SourceRevisionId)</RepositoryCommit> |
| 47 | + <RepositorySha Condition="'$(RepositorySha)' == ''">$(SourceRevisionId.Substring(0, 9))</RepositorySha> |
| 48 | + </PropertyGroup> |
| 49 | + |
| 50 | + <!-- Add SourceRoot as a project property too --> |
| 51 | + <ItemGroup> |
| 52 | + <_ThisAssemblyGitSourceRoot Include="@(SourceRoot -> WithMetadataValue('SourceControl', 'git'))" /> |
| 53 | + </ItemGroup> |
| 54 | + |
| 55 | + <PropertyGroup> |
| 56 | + <RepositoryRoot>@(_ThisAssemblyGitSourceRoot)</RepositoryRoot> |
| 57 | + </PropertyGroup> |
| 58 | + |
| 59 | + </Target> |
| 60 | + |
| 61 | + <Target Name="PrepareGitConstants" |
| 62 | + BeforeTargets="PrepareConstants" |
| 63 | + DependsOnTargets="InitializeGitInformation"> |
| 64 | + <ItemGroup> |
| 65 | + <Constant Include="Branch" Value="$(RepositoryBranch)" Root="Git" /> |
| 66 | + <Constant Include="Commit" Value="$(RepositoryCommit)" Root="Git" /> |
| 67 | + <Constant Include="Sha" Value="$(RepositorySha)" Root="Git" /> |
| 68 | + <Constant Include="Root" Value="$(RepositoryRoot.Replace('\', '/'))" Root="Git" /> |
| 69 | + <Constant Include="Url" Value="$(RepositoryUrl)" Root="Git" /> |
| 70 | + </ItemGroup> |
| 71 | + </Target> |
| 72 | + |
| 73 | +</Project> |
0 commit comments