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

Commit

Permalink
create embed nupkgs (#207)
Browse files Browse the repository at this point in the history
* create SourceLink.Embed.AllSourceFiles nupkg #205

* updated readme for embedding

* only portable or embedded

* updated known issues
  • Loading branch information
ctaggart committed May 2, 2017
1 parent cae7162 commit dfa9e63
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 10 deletions.
46 changes: 40 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ SourceLink v2 helps enable source link support using the [Portable PDB](https://

# Quick Start

The [source link documention](https://github.com/dotnet/core/blob/master/Documentation/diagnostics/source_link.md) shows how to embed a source link file by running `git` commands. That is exactly how the [targets](https://github.com/ctaggart/SourceLink/blob/v2/SourceLink.Create.CommandLine/SourceLink.Create.CommandLine.targets) file for SourceLink.Create.CommandLine works. Simply add a `PackageReference`. A common way to do with is by adding it to your projects in a `Directory.Build.props`:
The [source link documention](https://github.com/dotnet/core/blob/master/Documentation/diagnostics/source_link.md) shows how to embed a source link file by running `git` commands. That is exactly how the [targets](https://github.com/ctaggart/SourceLink/blob/v2/SourceLink.Create.CommandLine/SourceLink.Create.CommandLine.targets) file for `SourceLink.Create.CommandLine` works. Simply add a `PackageReference`. A common way to do with is by adding it to your projects in a `Directory.Build.props`:
``` xml
<Project>
<ItemGroup>
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.1.0" PrivateAssets="All" />
<PackageReference Include="SourceLink.Create.CommandLine" Version="2.1.1" PrivateAssets="All" />
</ItemGroup>
</Project>
```
Expand Down Expand Up @@ -65,7 +65,7 @@ msbuild /t:rebuild /p:ci=true /v:n

Install by adding:
``` xml
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.1.0" />
<DotNetCliToolReference Include="dotnet-sourcelink" Version="2.1.1" />
```

## examples
Expand All @@ -74,7 +74,7 @@ Install by adding:

`dotnet sourcelink test` may also be run by using the `SourceLink.Test` MSBuild targets.
``` xml
<PackageReference Include="SourceLink.Test" Version="2.1.0" PrivateAssets="all" />
<PackageReference Include="SourceLink.Test" Version="2.1.1" PrivateAssets="all" />
```
Just like the `SourceLinkCreate` property, you can control when it is enabled by setting the `SourceLinkTest` property.

Expand All @@ -85,6 +85,40 @@ Please follow the quick start if you are just getting started. `SourceLink.Creat
`SourceLink.Create.GitHub` and `SourceLink.Create.BitBucket` both use `dotnet sourcelink-git`, which accesses the git information using [libgit2sharp](https://github.com/libgit2/libgit2sharp). This allows some additional features. It verifies that all of the source files are in the git repository and that their checksums match. If checksums do not match due to line endings, it will automatically fix them to match the git repository like endings of `lf`. If a source file's checksum still does not match, it will be embedded. If the source file is not in the git repository, it will be embedded. All of these settings are configurable.

``` xml
<PackageReference Include="SourceLink.Create.GitHub" Version="2.1.0" PrivateAssets="all" />
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.1.0" />
<PackageReference Include="SourceLink.Create.GitHub" Version="2.1.1" PrivateAssets="all" />
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.1.1" />
```

# Embedding Source Files

For source files are not committed to the repository, it is helpful to embed them, so that they are available while debugging. Source files are not committed often when generated or downloaded from elsewhere.

## All Source Files

If you just want to embed all of the source files in the pdb and not use source link, add this package:
``` xml
<PackageReference Include="SourceLink.Embed.AllSourceFiles" Version="2.1.1" PrivateAssets="all" />
```

## Paket Files

If you are using `SourceLink.Create.CommandLine` and [Paket](https://fsprojects.github.io/Paket/)'s support for including source code that is not in your repository, you can embed those files in the pdb with:
``` xml
<PackageReference Include="SourceLink.Embed.PaketFiles" Version="2.1.1" PrivateAssets="all" />
```

# Known Issues

Please vote for all of these issues:

- GitHub NuGet: [msbuild /t:Pack always creates seperate symbols package](https://github.com/NuGet/Home/issues/4142)

`dotnet pack` and `msbuild /t:pack` need to support easily packaing portalbe pdb files.

- Visual Studio User Voice: [Debugger should support C# compiler '/embed' option](https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/19107733-debugger-should-support-c-compiler-embed-optio)

The Visual Studio 2017 debugger does not currently look for embedded source files.

- Visual Studio User Voice: [Debugger should support authentication with SourceLink](https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/19107784-debugger-should-support-authentication-with-source)

In order to use source link with private GitHub repositories and other private repositories, it needs to support authentication.
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,8 @@
</ItemGroup>

<!--<Import Project="../build/sourcelink.props" />-->
<ItemGroup>
<PackageReference Include="SourceLink.Create.GitHub" Version="2.1.0" PrivateAssets="all" />
<DotNetCliToolReference Include="dotnet-sourcelink-git" Version="2.1.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>
<ItemGroup Label="dotnet pack instructions">
<Content Include="SourceLink.Embed.AllSourceFiles.targets">
<Pack>true</Pack>
<PackagePath>build</PackagePath>
</Content>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project>
<PropertyGroup>
<BuildDependsOn Condition="$(DebugType) == 'portable' or $(DebugType) == 'embedded'">EmbedAllSourceFiles;$(BuildDependsOn)</BuildDependsOn>
</PropertyGroup>
<Target Name="EmbedAllSourceFiles">
<ItemGroup>
<EmbeddedFiles Include="$([System.IO.Path]::GetFullPath('%(Compile.Identity)'))" />
</ItemGroup>
<CreateProperty Value="@(EmbeddedFiles)">
<Output TaskParameter="Value" PropertyName="embed" />
</CreateProperty>
</Target>
</Project>
12 changes: 12 additions & 0 deletions SourceLink.Embed.PaketFiles/SourceLink.Embed.PaketFiles.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
<IncludeBuildOutput>false</IncludeBuildOutput>
</PropertyGroup>
<ItemGroup Label="dotnet pack instructions">
<Content Include="SourceLink.Embed.PaketFiles.targets">
<Pack>true</Pack>
<PackagePath>build</PackagePath>
</Content>
</ItemGroup>
</Project>
14 changes: 14 additions & 0 deletions SourceLink.Embed.PaketFiles/SourceLink.Embed.PaketFiles.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project>
<PropertyGroup>
<BuildDependsOn Condition="$(DebugType) == 'portable' or $(DebugType) == 'embedded'">EmbedPaketFiles;$(BuildDependsOn)</BuildDependsOn>
</PropertyGroup>
<Target Name="EmbedPaketFiles">
<ItemGroup>
<EmbeddedFiles Include="$([System.IO.Path]::GetFullPath('%(Compile.Identity)'))"
Condition="$([System.String]::Copy('%(Identity)').Contains('paket-files'))" />
</ItemGroup>
<CreateProperty Value="@(EmbeddedFiles)">
<Output TaskParameter="Value" PropertyName="embed" />
</CreateProperty>
</Target>
</Project>
34 changes: 31 additions & 3 deletions SourceLink.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26228.9
VisualStudioVersion = 15.0.26403.7
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{876D3926-2BE5-40B4-B9D4-1218875A3870}"
ProjectSection(SolutionItems) = preProject
Expand All @@ -21,9 +21,13 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Tests", "Tests\Tests.csproj
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceLink.Test", "SourceLink.Test\SourceLink.Test.csproj", "{76A52AA7-0433-4B6C-831C-2C2CEB371082}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceLink.Create.CommandLine", "SourceLink.Create.CommandLine\SourceLink.Create.CommandLine.csproj", "{FB0D8C0B-27DF-4D20-9F15-09794D95F744}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceLink.Create.CommandLine", "SourceLink.Create.CommandLine\SourceLink.Create.CommandLine.csproj", "{FB0D8C0B-27DF-4D20-9F15-09794D95F744}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceLink.Create.BitBucket", "SourceLink.Create.BitBucket\SourceLink.Create.BitBucket.csproj", "{76CC64F0-2D47-4B3C-ADEA-6E758953F2D3}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SourceLink.Create.BitBucket", "SourceLink.Create.BitBucket\SourceLink.Create.BitBucket.csproj", "{76CC64F0-2D47-4B3C-ADEA-6E758953F2D3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceLink.Embed.AllSourceFiles", "SourceLink.Embed.AllSourceFiles\SourceLink.Embed.AllSourceFiles.csproj", "{A791FDDC-9BAD-441B-9545-C26D2292E5C3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourceLink.Embed.PaketFiles", "SourceLink.Embed.PaketFiles\SourceLink.Embed.PaketFiles.csproj", "{81801FB5-9388-43BA-B8FD-508A428C03CF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -119,6 +123,30 @@ Global
{76CC64F0-2D47-4B3C-ADEA-6E758953F2D3}.Release|x64.Build.0 = Release|Any CPU
{76CC64F0-2D47-4B3C-ADEA-6E758953F2D3}.Release|x86.ActiveCfg = Release|Any CPU
{76CC64F0-2D47-4B3C-ADEA-6E758953F2D3}.Release|x86.Build.0 = Release|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Debug|x64.ActiveCfg = Debug|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Debug|x64.Build.0 = Debug|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Debug|x86.ActiveCfg = Debug|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Debug|x86.Build.0 = Debug|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Release|Any CPU.Build.0 = Release|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Release|x64.ActiveCfg = Release|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Release|x64.Build.0 = Release|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Release|x86.ActiveCfg = Release|Any CPU
{A791FDDC-9BAD-441B-9545-C26D2292E5C3}.Release|x86.Build.0 = Release|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Debug|x64.ActiveCfg = Debug|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Debug|x64.Build.0 = Debug|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Debug|x86.ActiveCfg = Debug|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Debug|x86.Build.0 = Debug|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Release|Any CPU.Build.0 = Release|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Release|x64.ActiveCfg = Release|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Release|x64.Build.0 = Release|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Release|x86.ActiveCfg = Release|Any CPU
{81801FB5-9388-43BA-B8FD-508A428C03CF}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
10 changes: 9 additions & 1 deletion build.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$version = '2.1.0' # the version under development, update after a release
$versionSuffix = '-a121' # manually incremented for local builds
$versionSuffix = '-a122' # manually incremented for local builds

function isVersionTag($tag){
$v = New-Object Version
Expand Down Expand Up @@ -42,6 +42,14 @@ Set-Location $psscriptroot\SourceLink.Test
dotnet restore
dotnet $pack

Set-Location $psscriptroot\SourceLink.Embed.AllSourceFiles
dotnet restore
dotnet $pack

Set-Location $psscriptroot\SourceLink.Embed.PaketFiles
dotnet restore
dotnet $pack

Set-Location $psscriptroot\build
dotnet restore
$nupkgs = ls ..\bin\*$version$versionSuffix.nupkg
Expand Down

0 comments on commit dfa9e63

Please sign in to comment.