控制构建定义文件的 pdb 文件输出
我正在尝试生成一个不生成 pdb 文件的发布版本。我看到很多帖子建议右键单击项目,选择“属性”,转到“构建”选项卡,然后转到“高级...”按钮并将“调试信息”更改为“无”。这一切都有效,但我需要为约 50 个解决方案的构建执行此操作,每个解决方案包含约 25 个项目!其他帖子提到编辑适当的 .csproj 文件,但同样,对于如此多的项目,这将需要很长时间。有什么方法可以通过 TFSBuild.proj 文件实现此目的吗?
我尝试将以下内容添加到 TFSBuild.proj 文件中,但没有成功。
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</PropertyGroup>
<PropertyGroup>
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
</PropertyGroup>
以下行打印出 Release|AnyCPU、none 和 false,但我仍然在 $(OutputDir) 文件夹中看到 .pdb 文件。
<Message Text="$Configuration|Platform): $(Configuration)|$(Platform)" />
<Message Text="DebugType is: $(DebugType)"/>
<Message Text="DebugSymbols is: $(DebugSymbols)"/>
提前致谢, 乌尔维
I am trying to generate a release build with no pdb files generated. I have seen numerous posts that suggest right-clicking on the project, selecting Properties, going to the Build tab and then to the Advanced... butoon and changing Debug Info to none. This works and all, but I need to do this for a build of ~50 solutions which contain ~25 projects each! Other posts mention editing the appropriate .csproj file, but again, with so many projects, this would take a long time. Is there any way to achieve this via the TFSBuild.proj file?
I have tried adding the following to the TFSBuild.proj file, with no luck.
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</PropertyGroup>
<PropertyGroup>
<DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType>
<Optimize>true</Optimize>
</PropertyGroup>
The following line prints out Release|AnyCPU, none, and false, but I still see .pdb file in the $(OutputDir) folder.
<Message Text="$Configuration|Platform): $(Configuration)|$(Platform)" />
<Message Text="DebugType is: $(DebugType)"/>
<Message Text="DebugSymbols is: $(DebugSymbols)"/>
Thanks in advance,
Urvi
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不完全确定(没有安装团队构建),但是当您更改 TFSBuild 项目中的此类属性时,它们很可能不会传播到您的实际项目文件,因为实际的解决方案/项目是通过启动构建的另一个 MSBuild 任务,并且 Microsoft.TeamFoundation.Build.targets 中的负责目标不会将这些属性传递给该任务。
例如,这是上述文件中的目标“CallCompile”(同样,我不确定这是否是您的构建场景所使用的,但想法是相同的):
所以您可能 无需将所需的属性添加到目标文件中,但是:
方法来实现您想要的,就是用您选择的语言编写一个脚本,列出某个目录下的所有 *.csproj 文件,然后修改每个文件以将 true 替换为 false。或者甚至更快:在资源管理器中搜索 *.csproj,在编辑器中一次打开所有文件,并对所有打开的文件执行查找/替换。
I am not entirely sure (don't have team build installed), but it is very likely that when you change such properties in the TFSBuild poject, they do not propagate to your actual project files since the actual solutions/projects are built by launching another MSBuild task, and the responsible target in Microsoft.TeamFoundation.Build.targets does not pass those Properties to the task.
For example, this is the target "CallCompile" in aforementioned file (again, I'm not sure if this is what your build scenario uses but the idea is the same):
So you might get away with adding the properties you want to the targets file, but:
One way to achive what you want, is to write a script in your language of choice that lists all *.csproj files under a certain directory, then modifies each file to replace true with false. Or even faster: do a search on *.csproj in explorer, open all files at once in an editor and perform a Find/Replace on all open files.