|
16 | 16 |
|
17 | 17 | <Import Project="$(EngRoot)targets/InternalsVisibleTo.targets" /> |
18 | 18 |
|
| 19 | + <!-- What follows is copied from:https://github.com/Azure/azure-functions-host/blob/dev/eng/build/RepositoryInfo.targets --> |
| 20 | + <!-- The following build target allows us to reconstruct source-link information when building in 1ES --> |
| 21 | + |
| 22 | + <!-- |
| 23 | + The convention for names of Azure DevOps repositories mirrored from GitHub is "{GitHub org name}.{GitHub repository name}". |
| 24 | + --> |
| 25 | + <PropertyGroup> |
| 26 | + <!-- There are quite a few git repo forms: |
| 27 | + https://[email protected]/azfunc/internal/_git/azure.azure-functions-host |
| 28 | + https://dev.azure.com/azfunc/internal/_git/azure.azure-functions-host |
| 29 | + https://azfunc.visualstudio.com/internal/_git/azure.azure-functions-host |
| 30 | + [email protected]:v3/azfunc/internal/azure.azure-functions-host |
| 31 | + [email protected]:v3/azfunc/internal/azure.azure-functions-host |
| 32 | + --> |
| 33 | + <!-- Set DisableSourceLinkUrlTranslation to true when building a tool for internal use where sources only come from internal URIs --> |
| 34 | + <DisableSourceLinkUrlTranslation Condition="'$(DisableSourceLinkUrlTranslation)' == ''">false</DisableSourceLinkUrlTranslation> |
| 35 | + <_TranslateUrlPattern>(https://azfunc%40dev\.azure\.com/azfunc/internal/_git|https://dev\.azure\.com/azfunc/internal/_git|https://azfunc\.visualstudio\.com/internal/_git|azfunc%40vs-ssh\.visualstudio\.com:v3/azfunc/internal|git%40ssh\.dev\.azure\.com:v3/azfunc/internal)/([^/\.]+)\.(.+)</_TranslateUrlPattern> |
| 36 | + <_TranslateUrlReplacement>https://github.com/$2/$3</_TranslateUrlReplacement> |
| 37 | + </PropertyGroup> |
| 38 | + |
| 39 | + <!-- When building from Azure Devops we update SourceLink to point back to the GitHub repo. --> |
| 40 | + <Target Name="_TranslateAzureDevOpsUrlToGitHubUrl" |
| 41 | + Condition="'$(DisableSourceLinkUrlTranslation)' == 'false'" |
| 42 | + DependsOnTargets="$(SourceControlManagerUrlTranslationTargets)" |
| 43 | + BeforeTargets="SourceControlManagerPublishTranslatedUrls"> |
| 44 | + <PropertyGroup> |
| 45 | + <ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace($(ScmRepositoryUrl), $(_TranslateUrlPattern), $(_TranslateUrlReplacement)))</ScmRepositoryUrl> |
| 46 | + </PropertyGroup> |
| 47 | + <ItemGroup> |
| 48 | + <SourceRoot Update="@(SourceRoot)"> |
| 49 | + <ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace(%(SourceRoot.ScmRepositoryUrl), $(_TranslateUrlPattern), $(_TranslateUrlReplacement)))</ScmRepositoryUrl> |
| 50 | + </SourceRoot> |
| 51 | + </ItemGroup> |
| 52 | + </Target> |
19 | 53 | </Project> |
0 commit comments