diff options
Diffstat (limited to '.packages/microsoft.sourcelink.github/1.0.0-beta2-19380-04/build/Microsoft.SourceLink.GitHub.targets')
-rwxr-xr-x | .packages/microsoft.sourcelink.github/1.0.0-beta2-19380-04/build/Microsoft.SourceLink.GitHub.targets | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/.packages/microsoft.sourcelink.github/1.0.0-beta2-19380-04/build/Microsoft.SourceLink.GitHub.targets b/.packages/microsoft.sourcelink.github/1.0.0-beta2-19380-04/build/Microsoft.SourceLink.GitHub.targets new file mode 100755 index 0000000000..796d099418 --- /dev/null +++ b/.packages/microsoft.sourcelink.github/1.0.0-beta2-19380-04/build/Microsoft.SourceLink.GitHub.targets @@ -0,0 +1,67 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project> + <PropertyGroup> + <_SourceLinkGitHubAssemblyFile Condition="'$(MSBuildRuntimeType)' != 'Core'">$(MSBuildThisFileDirectory)..\tools\net461\Microsoft.SourceLink.GitHub.dll</_SourceLinkGitHubAssemblyFile> + <_SourceLinkGitHubAssemblyFile Condition="'$(MSBuildRuntimeType)' == 'Core'">$(MSBuildThisFileDirectory)..\tools\netcoreapp2.0\Microsoft.SourceLink.GitHub.dll</_SourceLinkGitHubAssemblyFile> + </PropertyGroup> + + <UsingTask TaskName="Microsoft.SourceLink.GitHub.GetSourceLinkUrl" AssemblyFile="$(_SourceLinkGitHubAssemblyFile)"/> + <UsingTask TaskName="Microsoft.SourceLink.GitHub.TranslateRepositoryUrls" AssemblyFile="$(_SourceLinkGitHubAssemblyFile)"/> + + <PropertyGroup> + <SourceLinkUrlInitializerTargets>$(SourceLinkUrlInitializerTargets);_InitializeGitHubSourceLinkUrl</SourceLinkUrlInitializerTargets> + <SourceControlManagerUrlTranslationTargets>$(SourceControlManagerUrlTranslationTargets);TranslateGitHubUrlsInSourceControlInformation</SourceControlManagerUrlTranslationTargets> + </PropertyGroup> + + <Target Name="_InitializeGitHubSourceLinkUrl" Inputs="@(SourceRoot)" Outputs="|%(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 SourceLinkGitHubHost item group). + In addition SourceLinkHasSingleProvider is true an iplicit host is parsed from RepositoryUrl. + + Example of SourceLinkGitHubHost items: + + <ItemGroup> + <SourceLinkGitHubHost Include="github.com" ContentUrl="https://raw.githubusercontent.com"/> + <SourceLinkGitHubHost Include="mygithub1.com" /> ContentUrl defaults to https://mygithub1.com/raw + <SourceLinkGitHubHost Include="mygithub2.com:8080" /> ContentUrl defaults to https://mygithub2.com:8080/raw + </ItemGroup> + + ContentUrl is optional. If not specified it defaults to "https://{domain}/raw". + --> + <Microsoft.SourceLink.GitHub.GetSourceLinkUrl RepositoryUrl="$(PrivateRepositoryUrl)" SourceRoot="@(SourceRoot)" Hosts="@(SourceLinkGitHubHost)" IsSingleProvider="$(SourceLinkHasSingleProvider)"> + <Output TaskParameter="SourceLinkUrl" PropertyName="_SourceLinkUrlToUpdate"/> + </Microsoft.SourceLink.GitHub.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="TranslateGitHubUrlsInSourceControlInformation"> + + <ItemGroup> + <_TranslatedSourceRoot Remove="@(_TranslatedSourceRoot)"/> + </ItemGroup> + + <Microsoft.SourceLink.GitHub.TranslateRepositoryUrls RepositoryUrl="$(ScmRepositoryUrl)" SourceRoots="@(SourceRoot)" Hosts="@(SourceLinkGitHubHost)" IsSingleProvider="$(SourceLinkHasSingleProvider)"> + <Output TaskParameter="TranslatedRepositoryUrl" PropertyName="ScmRepositoryUrl"/> + <Output TaskParameter="TranslatedSourceRoots" ItemName="_TranslatedSourceRoot"/> + </Microsoft.SourceLink.GitHub.TranslateRepositoryUrls> + + <ItemGroup> + <SourceRoot Remove="@(SourceRoot)"/> + <SourceRoot Include="@(_TranslatedSourceRoot)"/> + </ItemGroup> + +</Target> + +</Project> |