Skip to content

Commit 789fc3d

Browse files
authored
[4.0] Fix | Enable source link translation (#2781)
1 parent ce929ff commit 789fc3d

File tree

6 files changed

+55
-4
lines changed

6 files changed

+55
-4
lines changed

src/Directory.Build.props

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,26 @@
6565
<DefineConstants>$(DefineConstants);ENCLAVE_SIMULATOR</DefineConstants>
6666
</PropertyGroup>
6767

68+
<!-- Packaging for source link-->
69+
<PropertyGroup>
70+
<DebugType>portable</DebugType>
71+
<DebugSymbols>true</DebugSymbols>
72+
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
73+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
74+
<EmbedUnTrackedSources>true</EmbedUnTrackedSources>
75+
<DisableSourceLinkTranslation Condition="'$(DisableSourceLinkTranslation)' == ''">false</DisableSourceLinkTranslation>
76+
</PropertyGroup>
77+
<PropertyGroup Condition="'$(TF_BUILD)' == 'true'">
78+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
79+
</PropertyGroup>
80+
6881
<!-- Provides Version properties -->
6982
<Import Project="$(ToolsDir)props\Versions.props" />
7083
<!-- Provides Tool properties -->
7184
<Import Project="$(ToolsDir)props\Tools.props" />
7285
<!-- Provides Build properties -->
7386
<Import Project="$(ToolsDir)props\AssemblyInfo.props" />
7487
<Import Project="$(ToolsDir)props\AssemblyRef.props" />
88+
<Import Project="$(ToolsDir)targets\RepositoryInfo.targets" />
89+
7590
</Project>

src/Microsoft.Data.SqlClient/add-ons/AzureKeyVaultProvider/Microsoft.Data.SqlClient.AlwaysEncrypted.AzureKeyVaultProvider.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
<PackageReference Condition="$(ReferenceType.Contains('Package'))" Include="Microsoft.Data.SqlClient" Version="$(TestMicrosoftDataSqlClientVersion)" />
2323
</ItemGroup>
2424
<ItemGroup>
25-
<PackageReference Condition="$(BuildForRelease) == 'true'" Include="Microsoft.SourceLink.GitHub" Version="$(MicrosoftSourceLinkGitHubVersion)" PrivateAssets="All" />
2625
<PackageReference Include="Azure.Core" Version="$(AzureCoreVersion)" />
2726
<PackageReference Include="System.Text.Encodings.Web" Version="$(SystemTextEncodingsWebVersion)" />
2827
<PackageReference Include="Azure.Security.KeyVault.Keys" Version="$(AzureSecurityKeyVaultKeysVersion)" />

src/Microsoft.Data.SqlClient/netcore/src/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,6 @@
940940
<PackageReference Include="System.Runtime.Caching" Version="$(SystemRuntimeCachingVersion)" />
941941
<PackageReference Condition="$(TargetGroup) == 'netstandard'" Include="System.Runtime.Loader" Version="$(SystemRuntimeLoaderVersion)" />
942942
<PackageReference Include="System.Security.Cryptography.Cng" Version="$(SystemSecurityCryptographyCngVersion)" />
943-
<PackageReference Condition="$(BuildForRelease) == 'true'" Include="Microsoft.SourceLink.GitHub" Version="$(MicrosoftSourceLinkGitHubVersion)" PrivateAssets="All" />
944943
</ItemGroup>
945944
<Import Project="$(ToolsDir)targets\GenerateThisAssemblyCs.targets" />
946945
<Import Project="$(ToolsDir)targets\ResolveContract.targets" Condition="'$(OSGroup)' == 'AnyOS'" />

src/Microsoft.Data.SqlClient/netfx/src/Microsoft.Data.SqlClient.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,6 @@
676676
</COMReference>
677677
</ItemGroup>
678678
<ItemGroup>
679-
<PackageReference Condition="$(BuildForRelease) == 'true'" Include="Microsoft.SourceLink.GitHub" Version="$(MicrosoftSourceLinkGitHubVersion)" PrivateAssets="All" />
680679
<PackageReference Include="System.Text.Encodings.Web">
681680
<Version>$(SystemTextEncodingsWebVersion)</Version>
682681
</PackageReference>

tools/props/Versions.props

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
<SystemBuffersVersion>4.5.1</SystemBuffersVersion>
2828
<SystemIOVersion>4.3.0</SystemIOVersion>
2929
<SystemTextEncodingsWebVersion>4.7.2</SystemTextEncodingsWebVersion>
30-
<MicrosoftSourceLinkGitHubVersion>1.0.0</MicrosoftSourceLinkGitHubVersion>
3130
</PropertyGroup>
3231
<!-- NetCore project dependencies -->
3332
<PropertyGroup>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this
2+
file to you under the MIT license. -->
3+
<Project>
4+
5+
<!-- Opt-in switch to disable source link (i.e. for local builds). -->
6+
<PropertyGroup Condition="'$(DisableSourceLink)' == 'true'">
7+
<EnableSourceLink>false</EnableSourceLink>
8+
<EnableSourceControlManagerQueries>false</EnableSourceControlManagerQueries>
9+
<DeterministicSourcePaths>false</DeterministicSourcePaths>
10+
</PropertyGroup>
11+
12+
<ItemGroup>
13+
<SourceRoot Include="$(RepoRoot)" />
14+
</ItemGroup>
15+
16+
<PropertyGroup>
17+
<_TranslateUrlPattern>https://[^/]+/ADO.Net/_git/([^/-]+)-(.+)</_TranslateUrlPattern>
18+
<_TranslateUrlReplacement>https://github.com/dotnet/SqlClient</_TranslateUrlReplacement>
19+
</PropertyGroup>
20+
21+
<Target Name="_TranslateAzureDevOpsUrlToGitHubUrl"
22+
Condition="'$(DisableSourceLinkTranslation)' == 'false'"
23+
DependsOnTargets="$(SourceControlManagerUrlTranslationTargets)"
24+
BeforeTargets="SourceControlManagerPublishTranslatedUrls">
25+
26+
<PropertyGroup>
27+
<ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace($(ScmRepositoryUrl), $(_TranslateUrlPattern), $(_TranslateUrlReplacement)))</ScmRepositoryUrl>
28+
</PropertyGroup>
29+
30+
<ItemGroup>
31+
<SourceRoot Update="@(SourceRoot)">
32+
</SourceRoot>
33+
<SourceRoot Update="@(SourceRoot)">
34+
<ScmRepositoryUrl>$([System.Text.RegularExpressions.Regex]::Replace(%(SourceRoot.ScmRepositoryUrl),
35+
$(_TranslateUrlPattern), $(_TranslateUrlReplacement)))</ScmRepositoryUrl>
36+
</SourceRoot>
37+
</ItemGroup>
38+
<Message Text="Final Translated ScmRepositoryUrl to $(ScmRepositoryUrl)" Importance="high" />
39+
</Target>
40+
</Project>

0 commit comments

Comments
 (0)