可以只删除编译后的程序之外的每个其他文件吗?

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

Can I delete every other file than the compiled program?

问题

当我在Visual Studio(2022)中构建解决方案时,它生成一个EXE(如果我选择了类库,则生成DLL),与预期一样,但它还会生成一些文件,如PDB和一些CS文件。我知道它们大部分的作用,但如果我正在制作一个由多个这些文件组成的软件,我不希望或喜欢一些人查看应用程序目录并找到源文件和/或源代码和解决方案。这让我产生了一个问题:删除除了已编译的EXE或DLL之外的每个文件会影响它们的可用性,还是有其他情况需要避免创建这些文件,比如SLN或PDB?

提前感谢:)

我什么都没有尝试,因为我根本不知道如何防止VS创建这些文件,除了已编译的文件。

英文:

When I build solution in Visual Studio (2022), it generates an EXE (or DLL if I chose a class library) just as expected, except it also generates some files, like PDB, and some CS files. I know what most of them do, but if I am making a software, which consists of multiple of these files, I wouldn't want or like some people looking at the application directory and find source files and/or source code and solutions. This makes me come up with a question: Would deleting every single file except the compiled EXE or DLL impact their usability, or is there any other circumstance(s) to avoid creating these files, like SLN or PDB?

Thanks in advance 可以只删除编译后的程序之外的每个其他文件吗?

<sub>I have not tried anything, because, I simply don't know how to prevent VS from creating these files, except compiled files.</sub>

答案1

得分: 2

.pdb 文件是您编译的输出文件。您可以使用以下方式抑制它们:

&lt;DebugSymbols&gt;false&lt;/DebugSymbols&gt;

其他文件,如 .cs.sln,是您项目的输入文件。删除它们意味着您将无法再构建您的程序。我不明白为什么您希望将它们删除。如果它们出现在您的输出目录中,请检查您的项目中是否将这些项目设置为“本地复制”(CopyToOutputDirectory)。

英文:

The .pdb files are outputs of your compilation. You can suppress them with:

&lt;DebugSymbols&gt;false&lt;/DebugSymbols&gt;

The other files, like .cs and .sln are inputs to your project. Deleting them will mean you cannot build your program any more. I don't understand why you would want them to be deleted. If they're appearing in your output directory, check that you don't have "Copy local" (CopyToOutputDirectory) set on those items in your project.

huangapple
  • 本文由 发表于 2023年2月19日 22:38:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/75500880.html
匿名

发表评论

匿名网友

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

确定