Skip to content

Commit 199b832

Browse files
committed
Enabling source link support
1 parent b0cf84d commit 199b832

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

build/common.props

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,32 @@
2020
<PackageIconUrl>https://raw.githubusercontent.com/Azure/azure-webjobs-sdk/dev/webjobs.png</PackageIconUrl>
2121
<CodeAnalysisRuleSet>$(MSBuildThisFileDirectory)..\src\src.ruleset</CodeAnalysisRuleSet>
2222
<NoWarn>$(NoWarn);NU1701</NoWarn>
23+
<DebugType>embedded</DebugType>
24+
<UseSourceLink Condition="$(UseSourceLink) == '' And $(CI) != ''">true</UseSourceLink>
2325
</PropertyGroup>
2426

27+
<PropertyGroup Condition="'$(UseSourceLink)' == 'true'">
28+
<SourceLink>$(BaseIntermediateOutputPath)source_link.json</SourceLink>
29+
</PropertyGroup>
30+
31+
<Target Name="GenerateSourceLink" BeforeTargets="CoreCompile" Condition="'$(UseSourceLink)' == 'true'">
32+
<PropertyGroup>
33+
<SrcRootDirectory>$([System.IO.Directory]::GetParent($(MSBuildThisFileDirectory.TrimEnd("\"))))</SrcRootDirectory>
34+
<SourceLinkRoot>$(SrcRootDirectory.Replace("\", "\\"))</SourceLinkRoot>
35+
</PropertyGroup>
36+
<Message Importance="high" Text="Generating SourceLink..."></Message>
37+
<Exec Command="git config --get remote.origin.url" ConsoleToMsBuild="true">
38+
<Output TaskParameter="ConsoleOutput" PropertyName="RemoteUri" />
39+
</Exec>
40+
41+
<Exec Command="git rev-parse HEAD" ConsoleToMsBuild="true" Condition = " '$(LatestCommit)' == '' ">
42+
<Output TaskParameter="ConsoleOutput" PropertyName="LatestCommit" />
43+
</Exec>
44+
45+
<!-- Write out the source file for this project to point at raw.githubusercontent.com -->
46+
<WriteLinesToFile File="$(BaseIntermediateOutputPath)source_link.json" Overwrite="true" Lines='{"documents": { "$(SourceLinkRoot)\\*" : "$(RemoteUri.Replace(".git", "").Replace("github.com", "raw.githubusercontent.com"))/$(LatestCommit)/*" }}' />
47+
</Target>
48+
2549
<ItemGroup>
2650
<AdditionalFiles Include="$(MSBuildThisFileDirectory)..\stylecop.json" Link="stylecop.json" />
2751
</ItemGroup>

0 commit comments

Comments
 (0)