|
83 | 83 | <Target Name="CleanIntermediateFiles" AfterTargets="Build" Condition="'$(WindowsAppSDKCleanIntermediateFiles)' == 'true'"> |
84 | 84 | <RemoveDir Directories="$(IntermediateOutputPath)" /> |
85 | 85 | </Target> |
| 86 | + |
| 87 | + <!-- |
| 88 | + This repository is mirrored to an internal repository in Azure Devops that is used for the official build. |
| 89 | + We need to translate the internal AzDO URLs into Github URLs in order for SourceLink to properly resolve |
| 90 | + source code. |
| 91 | +
|
| 92 | + The logic for doing this was adapted from the Arcade SDK (https://github.com/dotnet/arcade/blob/8fe02bab989df1265eee225df2c28af6dbdccc83/src/Microsoft.DotNet.Arcade.Sdk/tools/RepositoryInfo.targets#L36-L75). |
| 93 | + --> |
| 94 | + <PropertyGroup> |
| 95 | + <!-- There are a few git repo forms: |
| 96 | + https://[email protected]/microsoft/ProjectReunion/_git/WindowsAppSDK |
| 97 | + https://dev.azure.com/microsoft/ProjectReunion/_git/WindowsAppSDK |
| 98 | + --> |
| 99 | + <!-- Set DisableSourceLinkUrlTranslation to true when building a tool for internal use where sources only come from internal URIs --> |
| 100 | + <DisableSourceLinkUrlTranslation Condition="'$(DisableSourceLinkUrlTranslation)' == ''">false</DisableSourceLinkUrlTranslation> |
| 101 | + <_TranslateUrlPattern>(https://microsoft%40dev.azure.com/microsoft/ProjectReunion/_git/WindowsAppSDK|https://dev.azure.com/microsoft/ProjectReunion/_git/WindowsAppSDK|https://microsoft.visualstudio.com/ProjectReunion/_git/WindowsAppSDK)</_TranslateUrlPattern> |
| 102 | + <_TranslateUrlReplacement>https://github.com/microsoft/WindowsAppSDK.git</_TranslateUrlReplacement> |
| 103 | + </PropertyGroup> |
| 104 | + |
| 105 | + <Target Name="_TranslateAzureDevOpsUrlToGitHubUrl" |
| 106 | + Condition="'$(DisableSourceLinkUrlTranslation)' == 'false'" |
| 107 | + DependsOnTargets="$(SourceControlManagerUrlTranslationTargets)" |
| 108 | + BeforeTargets="SourceControlManagerPublishTranslatedUrls"> |
| 109 | + |
| 110 | + <PropertyGroup> |
| 111 | + <ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace($(ScmRepositoryUrl), $(_TranslateUrlPattern), $(_TranslateUrlReplacement)))</ScmRepositoryUrl> |
| 112 | + </PropertyGroup> |
| 113 | + |
| 114 | + <ItemGroup> |
| 115 | + <SourceRoot Update="@(SourceRoot)"> |
| 116 | + <ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace(%(SourceRoot.ScmRepositoryUrl), $(_TranslateUrlPattern), $(_TranslateUrlReplacement)))</ScmRepositoryUrl> |
| 117 | + <!-- As part of our deterministic build, we pass the `/d1trimfile:$(RepoRoot)` switch to the C++ compiler to remove the |
| 118 | + repo root from file paths embedded into the PDB, e.g. `d:\winappsdk\dev\MRTCore\mrt\Core\src\MRM.cpp` becomes |
| 119 | + `\dev\MRTCore\mrt\Core\src\MRM.cpp`. We thus need to tell Source Link about this mapping. --> |
| 120 | + <MappedPath Condition="'$(Language)'=='C++'">$([System.String]::Copy('%(SourceRoot.Identity)').Replace('$(RepoRoot)',''))</MappedPath> |
| 121 | + </SourceRoot> |
| 122 | + </ItemGroup> |
| 123 | + </Target> |
86 | 124 | </Project> |
0 commit comments