build/Targets/SourcePackage.targets (26 lines of code) (raw):
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -->
<Project>
<!--
Imported to project that produce source packages.
-->
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<PropertyGroup>
<!-- We only build to validate the code, we are not interested in any outputs. -->
<GenerateDocumentationFile>false</GenerateDocumentationFile>
<ProduceReferenceAssembly>false</ProduceReferenceAssembly>
<DebugType>none</DebugType>
<GenerateDependencyFile>false</GenerateDependencyFile>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<!-- Disables copying any build files to output dir -->
<SkipCopyBuildProduct>true</SkipCopyBuildProduct>
<!-- Disables copying any dependent files to output dir -->
<UseCommonOutputDirectory>true</UseCommonOutputDirectory>
</PropertyGroup>
<PropertyGroup>
<_SourcePackagePropsDirPath>$(OutputPath)SourcePackages\$(MSBuildProjectName)\</_SourcePackagePropsDirPath>
<_SourcePackagePropsFilePath>$(_SourcePackagePropsDirPath)$(PackageId).props</_SourcePackagePropsFilePath>
</PropertyGroup>
<!-- The condition ensures the target is only run once even if the project is cross-targeting. -->
<Target Name="GenerateSourcePackagePropsFile"
BeforeTargets="Build"
Condition="'$(TargetFrameworks)' == '' or '$(IsCrossTargetingBuild)' == 'true'"
Outputs="$(_SourcePackagePropsFilePath)">
<PropertyGroup>
<_RelativePath>$([MSBuild]::MakeRelative($(RepoRoot), $(MSBuildProjectDirectory)))</_RelativePath>
<!-- TODO: Proper URL escaping -->
<_RawUrl>$(RepositoryRawUrl)/$(GitHeadSha)/$(_RelativePath.Replace('\', '/'))/*</_RawUrl>
<_Content>
<![CDATA[<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<SourceRoot Include="%24([System.IO.Path]::GetFullPath('%24(MSBuildThisFileDirectory)..\contentFiles\cs\%24(TargetFramework)\'))"
SourceLinkUrl="$(_RawUrl)"/>
</ItemGroup>
</Project>]]>
</_Content>
</PropertyGroup>
<MakeDir Directories="$(_SourcePackagePropsDirPath)" />
<WriteLinesToFile File="$(_SourcePackagePropsFilePath)" Lines="$(_Content)" Overwrite="true" Encoding="UTF-8"/>
<ItemGroup>
<FileWrites Include="$(_SourcePackagePropsFilePath)" />
</ItemGroup>
</Target>
</Project>