Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUnTrackedSources>true</EmbedUnTrackedSources>
<DisableSourceLinkTranslation Condition="'$(DisableSourceLinkTranslation)' == ''">false</DisableSourceLinkTranslation>
</PropertyGroup>
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
Expand All @@ -96,4 +97,6 @@
<!-- Provides Build properties -->
<Import Project="$(ToolsDir)props\AssemblyInfo.props" />
<Import Project="$(ToolsDir)props\AssemblyRef.props" />
<Import Project="$(ToolsDir)targets\RepositoryInfo.targets" />

</Project>
40 changes: 40 additions & 0 deletions tools/targets/RepositoryInfo.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this
file to you under the MIT license. -->
<Project>

<!-- Opt-in switch to disable source link (i.e. for local builds). -->
<PropertyGroup Condition="'$(DisableSourceLink)' == 'true'">
<EnableSourceLink>false</EnableSourceLink>
<EnableSourceControlManagerQueries>false</EnableSourceControlManagerQueries>
<DeterministicSourcePaths>false</DeterministicSourcePaths>
</PropertyGroup>

<ItemGroup>
<SourceRoot Include="$(RepoRoot)" />
</ItemGroup>

<PropertyGroup>
<_TranslateUrlPattern>https://[^/]+/ADO.Net/_git/([^/-]+)-(.+)</_TranslateUrlPattern>
<_TranslateUrlReplacement>https://github.com/dotnet/SqlClient</_TranslateUrlReplacement>
</PropertyGroup>

<Target Name="_TranslateAzureDevOpsUrlToGitHubUrl"
Condition="'$(DisableSourceLinkTranslation)' == 'false'"
DependsOnTargets="$(SourceControlManagerUrlTranslationTargets)"
BeforeTargets="SourceControlManagerPublishTranslatedUrls">

<PropertyGroup>
<ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace($(ScmRepositoryUrl), $(_TranslateUrlPattern), $(_TranslateUrlReplacement)))</ScmRepositoryUrl>
</PropertyGroup>

<ItemGroup>
<SourceRoot Update="@(SourceRoot)">
</SourceRoot>
<SourceRoot Update="@(SourceRoot)">
<ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace(%(SourceRoot.ScmRepositoryUrl),
$(_TranslateUrlPattern), $(_TranslateUrlReplacement)))</ScmRepositoryUrl>
</SourceRoot>
</ItemGroup>
<Message Text="Final Translated ScmRepositoryUrl to $(ScmRepositoryUrl)" Importance="high" />
</Target>
</Project>