是否可能恢复启用EmbedAllSources的NuGet包的源代码?

huangapple go评论60阅读模式
英文:

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:

...
&lt;PropertyGroup&gt;
  &lt;!-- Omitted for brevity --&gt; 
  &lt;GeneratePackageOnBuild&gt;true&lt;/GeneratePackageOnBuild&gt;
  &lt;IncludeSymbols&gt;true&lt;/IncludeSymbols&gt;
  &lt;EmbedAllSources&gt;true&lt;/EmbedAllSources&gt;
  &lt;!-- Omitted for brevity --&gt; 
&lt;/PropertyGroup&gt;
...

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.

huangapple
  • 本文由 发表于 2020年1月6日 18:07:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/59610112.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定