-
Notifications
You must be signed in to change notification settings - Fork 56
How can I make this work with embedded source files? #192
Comments
If you are embedding all the source files, you do not need to enable source linking. You do not need this tool. I tried to explain this in the overview where I stated:
Were you asking how to embed all source files instead of enabling source link? If so, have a look at: C:\Program Files\dotnet\sdk\1.0.0\Roslyn\Microsoft.CSharp.Core.targets You will see that the C# Compiler takes in a <Csc Condition=" '%(_CoreCompileResourceInputs.WithCulture)' != 'true' "
EmbeddedFiles="@(EmbeddedFiles)" You can do something similar to what I did here with Directory.Build.targets for the Paket pull request and just remove the condition. This should work for both C# and F#: <Project>
<PropertyGroup>
<BuildDependsOn>EmbedAllFiles;$(BuildDependsOn)</BuildDependsOn>
</PropertyGroup>
<Target Name="EmbedAllFiles">
<ItemGroup>
<EmbeddedFiles Include="$([System.IO.Path]::GetFullPath('%(Compile.Identity)'))" />
</ItemGroup>
<CreateProperty Value="@(EmbeddedFiles)">
<Output TaskParameter="Value" PropertyName="embed" />
</CreateProperty>
</Target>
</Project> If it just C#, probably this will work: <Project>
<PropertyGroup>
<BuildDependsOn>EmbedAllFiles;$(BuildDependsOn)</BuildDependsOn>
</PropertyGroup>
<Target Name="EmbedAllFiles">
<ItemGroup>
<EmbeddedFiles Include="%(Compile.Identity)" />
</ItemGroup>
</Target>
</Project> Hope that helps. |
You can test if it worked by using |
Thanks @ctaggart. I think this approach would be my fallback in case I can't get it working properly with linking to GitHub. I'm having some trouble with that approach as well though. I'll comment here with any further information when I've gotten to the bottom of it. |
As a reference for other people, I finally got this working with the following <Project>
<Target Name="PopulateEmbeddedFiles" AfterTargets="BeforeCompile" BeforeTargets="CoreCompile"
Condition="'$(Configuration)'=='Release'">
<Message Importance="High" Text=" SKIPPED source file embedding for $(MSBuildProjectName) - DebugType: $(DebugType)"
Condition="'$(DebugType)'!='embedded' and '$(DebugType)'!='portable'" />
<Message Importance="High" Text="$(MSBuildProjectName) -> Embedding source files"
Condition="'$(DebugType)'=='embedded' or '$(DebugType)'=='portable'" />
<ItemGroup Condition="'$(DebugType)'=='embedded' or '$(DebugType)'=='portable'">
<EmbeddedFiles Include="@(Compile)" />
</ItemGroup>
</Target>
</Project> Obviously, the Also have a look at dotnet/roslyn#19127 which should make this obsolete by exposing |
Turns out I cheered to soon. 😢 If I embed the source files on a build server (windows) it no longer works. If I look at the generated DLL (from the nuget package),
If I try to step into this file in Visual Studio 2017, it fails to load the file and outputs this. Note that the hash is the same.
Any ideas? |
@cwe1ss I noticed that I couldn't step into some files when the code is compiled in Release, but I can if the code is compiled in Debug. |
@shaynevanasperen same result in my case. thx though! |
I think the debugger doesn't yet support extracting source files embedded in the .pdb. |
That's a bummer. I got really excited about this! 😢 This sounded like the perfect solution for internal libraries that sit in private repos. I'd still prefer this over enabling authenticated access to the repo because DLL size is not really a concern for our libraries and having to download each file separately seems unnecessary and slower. Do you know of any place on GitHub where I can vote for this? |
Hopefully @gregg-miskelly will get to it at some point soonish... Keep in mind though that the /embed option embeds the sources in the .pdb, not the .dll (unless of course you're embedding the .pdb itself in the .dll). |
I added a user voice item that folks can vote for and track progress: https://visualstudio.uservoice.com/forums/121579-visual-studio-ide/suggestions/19107733-debugger-should-support-c-compiler-embed-optio |
Awesome! I gave it my vote! thank you! Note that the link in your uservoice comment links to itself... not sure if this was intended?! |
@cwe1ss Thanks for noticing. Fixed. |
I created a The 2 user issues that @gregg-miskelly added yesterday as well as the lack of pdb pack support are now in the readme too under Known Issues. |
I want to be able to create a library that has an embedded PDB as well as embedded source files and have the SourceLink file be generated so that it points to the files that are embedded in the dll of the library rather than a URL. I can't figure out how to do this. Please update your documentation to make it more clear.
The text was updated successfully, but these errors were encountered: