<!-- Licensed to the .NET Foundation under one or more agreements. The .NET Foundation licenses this file to you under the MIT license. See the License.txt file in the project root for more information. --> <Project> <PropertyGroup> <_SourceLinkBitbucketAssemblyFile Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tools\net472\Microsoft.SourceLink.Bitbucket.Git.dll</_SourceLinkBitbucketAssemblyFile> <_SourceLinkBitbucketAssemblyFile Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tools\core\Microsoft.SourceLink.Bitbucket.Git.dll</_SourceLinkBitbucketAssemblyFile> </PropertyGroup> <UsingTask TaskName="Microsoft.SourceLink.Bitbucket.Git.GetSourceLinkUrl" AssemblyFile="$(_SourceLinkBitbucketAssemblyFile)"/> <UsingTask TaskName="Microsoft.SourceLink.Bitbucket.Git.TranslateRepositoryUrls" AssemblyFile="$(_SourceLinkBitbucketAssemblyFile)"/> <PropertyGroup> <SourceLinkUrlInitializerTargets>$(SourceLinkUrlInitializerTargets);_InitializeBitbucketGitSourceLinkUrl</SourceLinkUrlInitializerTargets> <SourceControlManagerUrlTranslationTargets>$(SourceControlManagerUrlTranslationTargets);TranslateBitbucketGitUrlsInSourceControlInformation</SourceControlManagerUrlTranslationTargets> </PropertyGroup> <Target Name="_InitializeBitbucketGitSourceLinkUrl" Outputs="%(SourceRoot.Identity)"> <!-- The task calculates SourceLink URL for a given SourceRoot. If the SourceRoot is associated with a git repository with a recognized domain the <see cref="SourceLinkUrl"/> output property is set to the content URL corresponding to the domain, otherwise it is set to string "N/A". Recognized domains are specified via Hosts (initialized from SourceLinkBitbucketGitHost item group). In addition, if SourceLinkHasSingleProvider is true an implicit host is parsed from RepositoryUrl. Example of SourceLinkBitbucketGitHost items: <ItemGroup> <SourceLinkBitbucketGitHost Include="bitbucket1.com" ContentUrl="http://bitbucket1.com"/> <SourceLinkBitbucketGitHost Include="bitbucket2.com" /> ContentUrl defaults to https://bitbucket2.com <SourceLinkBitbucketGitHost Include="bitbucket3.com:8080" /> ContentUrl defaults to https://bitbucket3.com:8080 </ItemGroup> ContentUrl is optional. If not specified it defaults to "https://{domain}" or "http://{domain}", based on the scheme of SourceRoot.RepositoryUrl. --> <Microsoft.SourceLink.Bitbucket.Git.GetSourceLinkUrl RepositoryUrl="$(PrivateRepositoryUrl)" SourceRoot="@(SourceRoot)" Hosts="@(SourceLinkBitbucketGitHost)" IsSingleProvider="$(SourceLinkHasSingleProvider)"> <Output TaskParameter="SourceLinkUrl" PropertyName="_SourceLinkUrlToUpdate"/> </Microsoft.SourceLink.Bitbucket.Git.GetSourceLinkUrl> <ItemGroup> <!-- Only update the SourceLinkUrl metadata if the SourceRoot belongs to this source control --> <SourceRoot Update="%(Identity)" SourceLinkUrl="$(_SourceLinkUrlToUpdate)" Condition="'$(_SourceLinkUrlToUpdate)' != 'N/A'"/> </ItemGroup> </Target> <!-- We need to translate ssh URLs to https. --> <Target Name="TranslateBitbucketGitUrlsInSourceControlInformation"> <ItemGroup> <_TranslatedSourceRoot Remove="@(_TranslatedSourceRoot)"/> </ItemGroup> <Microsoft.SourceLink.Bitbucket.Git.TranslateRepositoryUrls RepositoryUrl="$(ScmRepositoryUrl)" SourceRoots="@(SourceRoot)" Hosts="@(SourceLinkBitbucketGitHost)" IsSingleProvider="$(SourceLinkHasSingleProvider)"> <Output TaskParameter="TranslatedRepositoryUrl" PropertyName="ScmRepositoryUrl"/> <Output TaskParameter="TranslatedSourceRoots" ItemName="_TranslatedSourceRoot"/> </Microsoft.SourceLink.Bitbucket.Git.TranslateRepositoryUrls> <ItemGroup> <SourceRoot Remove="@(SourceRoot)"/> <SourceRoot Include="@(_TranslatedSourceRoot)"/> </ItemGroup> </Target> </Project> |