控制构建定义文件的 pdb 文件输出

发布于 2024-08-14 12:20:54 字数 917 浏览 7 评论 0原文

我正在尝试生成一个不生成 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你没皮卡萌 2024-08-21 12:20:54

我不完全确定(没有安装团队构建),但是当您更改 TFSBuild 项目中的此类属性时,它们很可能不会传播到您的实际项目文件,因为实际的解决方案/项目是通过启动构建的另一个 MSBuild 任务,并且 Microsoft.TeamFoundation.Build.targets 中的负责目标不会将这些属性传递给该任务。

例如,这是上述文件中的目标“CallCompile”(同样,我不确定这是否是您的构建场景所使用的,但想法是相同的):

<Target Name="CallCompile" DependsOnTargets="$(CoreCompileDependsOn)">
  <!-- Pass in all properties that users might want during the course of the compile targets. -->
  <MSBuild Projects="$(MSBuildProjectFile)"
           Properties="a lot of properties, but not DebugSymbols etc"
           Targets="CoreCompile">
  </MSBuild>
</Target>

所以您可能 无需将所需的属性添加到目标文件中,但是:

  • 这意味着您每次升级时都必须更改该文件,
  • 最后但并非最不重要
  • 的是:如果项目调用的文件还包含 DebugSymbols/...,文件中的属性值只是覆盖 MSBuild 任务传递的属性值,因此最终您仍然需要更改所有项目文件来处理该

方法来实现您想要的,就是用您选择的语言编写一个脚本,列出某个目录下的所有 *.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):

<Target Name="CallCompile" DependsOnTargets="$(CoreCompileDependsOn)">
  <!-- Pass in all properties that users might want during the course of the compile targets. -->
  <MSBuild Projects="$(MSBuildProjectFile)"
           Properties="a lot of properties, but not DebugSymbols etc"
           Targets="CoreCompile">
  </MSBuild>
</Target>

So you might get away with adding the properties you want to the targets file, but:

  • that means you have to change that file each time you upgrade
  • it might not be the desired behaviour for all your projects
  • last but not least: if the project files invoked also contain DebugSymbols/..., the property values in your file simply override the ones passed by the MSBuild task, so in the end you still have to change all project files to deal with that

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文