我有一个 Visual Studio 2008 C#/.NET 3.5 项目,其中包含一个用于压缩内容的后期构建任务。但是,我发现我还在输出目录(和 ZIP)中获取了引用程序集的 .pdb(调试)和 .xml(文档)文件。
例如,如果 MyProject.csproj 引用 YourAssembly.dll 并且在与 DLL 相同的目录中存在 YourAssembly.xml 和 YourAssembly.pdb 文件,它们将显示在我的输出目录(和 ZIP)中。
我可以在压缩时排除 *.pdb,但我不能完全排除 *.xml 文件,因为我有具有相同扩展名的部署文件。
有没有办法防止项目复制引用的程序集 PDB 和 XML 文件?
最佳答案
我希望能够在我的主应用程序中添加和删除引用的程序集,同时避免需要维护我需要删除或排除的文件。
我翻遍了 Microsoft.Common.targets
寻找可行的方法并找到了 AllowedReferenceRelatedFileExtensions
属性。默认为 .pdb; .xml
所以我在我的项目文件中明确定义了它。问题是你需要 something (空白是不够的)否则它仍然会使用默认值。
<Project ...>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
...
<AllowedReferenceRelatedFileExtensions>
<!-- Prevent default XML and PDB files copied to output in RELEASE.
Only *.allowedextension files will be included, which doesn't exist in my case.
-->
.allowedextension
</AllowedReferenceRelatedFileExtensions>
</PropertyGroup>
https://stackoverflow.com/questions/2011434/