Skip to content

Commit a820af7

Browse files
Fix Source Link information so it points to Github rather than internal AzDO mirror (#4666)
This repository is mirrored onto an internal Azure DevOps repository that is used for building Windows App SDK releases. This has the unfortunate side effect of embedding into the PDB symbols Source Link information that points at the internal AzDO repo rather than this public Github repo. This change addresses that by adding a custom target that corrects the repo URL that Source Link uses. Fixes #4633.
1 parent a538c82 commit a820af7

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

Directory.Build.props

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,42 @@
8383
<Target Name="CleanIntermediateFiles" AfterTargets="Build" Condition="'$(WindowsAppSDKCleanIntermediateFiles)' == 'true'">
8484
<RemoveDir Directories="$(IntermediateOutputPath)" />
8585
</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>
86124
</Project>

0 commit comments

Comments
 (0)