ctaggart / SourceLink

Source Code On Demand
MIT License
356 stars 55 forks source link

use EnableSourceLink instead of SourceLinkCreate #351

Closed ctaggart closed 6 years ago

ctaggart commented 6 years ago

The .NET Core 2.1 SDK has the ability to enable and disable source linking using the EnableSourceLink property. SourceLink v2 uses SourceLinkCreate property. SourceLink v3 will build on top the .NET SDK functionality, so SourceLinkCreate will be removed in favor of EnableSourceLink.

Its behavior is a bit different. It is enabled by default when run from the command line, but not an IDE like Visual Studio. Details are in:

https://github.com/dotnet/sourcelink/blob/master/src/SourceLink.Common/build/Microsoft.SourceLink.Common.props

tlorton commented 6 years ago

So would I add <EnableSourceLink>true</EnableSourceLink> in the .csproj of the library? Or in the .csproj of the project that wants to use the library?

ctaggart commented 6 years ago

@tlorton, when using libraries like Microsoft.SourceLink tools, EnableSourceLink is true be default when you are building from the command line. You don't have to do anything. In SourceLink.Create tools, SourceLinkCreate is false by default.

EnableSourceLink This property is implicitly set to true by a SourceLink package. Including a SourceLink package thus enables SourceLink generation unless explicitly disabled by the project by setting this property to false. https://github.com/dotnet/sourcelink/blob/master/docs/README.md#enablesourcelink

You can see the specific conditions for when EnableSourceLink in Microsoft.SourceLink.Commons.props:

    <!--
      Do not generate SourceLink when building in the IDE or for Live Unit Testing.
    -->
    <EnableSourceLink Condition="'$(EnableSourceLink)' == '' and '$(DesignTimeBuild)' != 'true' and '$(BuildingForLiveUnitTesting)' != 'true'">true</EnableSourceLink>
tlorton commented 6 years ago

Sorry, I neglected to mention that I am using Visual Studio 2017 IDE. From your response, I infer that once my team upgrades the .NET SDK to use .NET Core 2.1, we can then install the most recent SourceLink Nuget Package and that automatically comes default as true for EnableSourceLink, therefore not needing to set to true in the .csproj.