Skip to content
This repository has been archived by the owner on Apr 16, 2020. It is now read-only.

use EnableSourceLink instead of SourceLinkCreate #351

Closed
ctaggart opened this issue Jun 18, 2018 · 3 comments
Closed

use EnableSourceLink instead of SourceLinkCreate #351

ctaggart opened this issue Jun 18, 2018 · 3 comments
Milestone

Comments

@ctaggart
Copy link
Owner

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

@ctaggart ctaggart added this to the 3.0.0 milestone Jun 18, 2018
@tlorton
Copy link

tlorton commented Jul 17, 2018

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
Copy link
Owner Author

ctaggart commented Jul 18, 2018

@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
Copy link

tlorton commented Jul 18, 2018

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants