英文:
Is it possible to recover the source code of a nuget package built with EmbedAllSources enabled?
问题
我正在从一个 new-format-csproj 项目构建一个 NuGet 包。我在我的 csproj 文件中包含了 EmbedAllSources 属性(如下所示):
...
<PropertyGroup>
<!-- 省略部分内容 -->
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>true</IncludeSymbols>
<EmbedAllSources>true</EmbedAllSources>
<!-- 省略部分内容 -->
</PropertyGroup>
...
因为这个属性,是否有可能 NuGet 的消费者可以检索/重建我的 NuGet 的源代码呢?如果可以,如何实现?
英文:
I am building a nuget package from a new-format-csproj project. I included the EmbedAllSources property (see below) in my csproj file:
...
<PropertyGroup>
<!-- Omitted for brevity -->
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<IncludeSymbols>true</IncludeSymbols>
<EmbedAllSources>true</EmbedAllSources>
<!-- Omitted for brevity -->
</PropertyGroup>
...
Is it possible that consumers of my nuget, retrieve/reconstruct the source code of my nuget because of that property? If so, how?
答案1
得分: 2
是的。
使用dotnet core 3.1.201和一个最小的测试项目运行后,我得到了一个输出文件夹中的.nupkg
和.symbols.nupkg
文件。这些文件只是zip文件,所以可以以任何你喜欢的方式解压它们。.symbols.nupkg
文件包含了/libs/{framework}/
目录下的.pdb
文件。我甚至没有尝试做任何聪明的事情...只是将它放入notepad++中,你可以清楚地看到所有相关的源代码都在其中。将其提取为单独的.cs
文件会需要更多的努力,但不会太麻烦。
英文:
Yes.
Running this with dotnet core 3.1.201 and a minimal test project, I end up with a .nupkg
and a .symbols.nupkg
in the output folder. These files are just zips, so unzip them in any way you like. The .symbols.nupkg
file contains the .pdb
file under /libs/{framework}/
. I didn't even try to do anything clever... just chucked it into notepad++ and you can see clearly that all the relevant source is in there. Extracting it into individual .cs
files will take a bit more effort, but not too much more.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论