如何使用msbuild覆盖vbproj DebugSymbols?

时间:2009-07-24 20:28:22

标签: msbuild

无论我在各种vbproj文件中的DebugSymbols设置如何,我都要生成.pdb文件。

我有一个名为FX.proj的msbuild项目,如下所示:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <ProjectReferences Include="C:\product\forms.vbproj" />
    <ProjectReferences Include="C:\product\core.vbproj" />
    <ProjectReferences Include="C:\product\fx.vbproj" />
  </ItemGroup>
  <Target Name="Build">
    <MSBuild Projects="@(ProjectReferences)" Targets="Build" />
  </Target>
</Project>

我从命令行调用它:

  

msbuild / t:Build / v:Minimal / nologo“/ p:OutputPath =%~dp0bin; Configuration = Release”/ fl /flp:LogFile=FX.log;Verbosity=Normal FX.proj

我想覆盖每个vbproj中的DebugSymbols属性。

我试图将它添加到命令行,如下所示:

  

msbuild / t:Build / v:Minimal / nologo“/ p:OutputPath =%~dp0bin; Configuration = Release; DebugSymbols = true”/ fl /flp:LogFile=FX.log;Verbosity=Normal FX.proj < / p>

与MSBuild目标属性如下:

<Target Name="Build">
  <MSBuild Projects="@(ProjectReferences)" Targets="Build" Properties="DebugSymbols=true" />
</Target>

但似乎都不起作用。无论在vbproj中为指定的配置设置什么都会发生。

有什么想法吗?

1 个答案:

答案 0 :(得分:1)

我刚做了这件事,并插入了目标

  <Target Name="AfterBuild">
    <Message Text="DebugSymbols: $(DebugSymbols)" Importance="high" />
  </Target>

进入每个.vbproj文件(导入语句后的 )。这是我的整个FX.proj文件。

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <ItemGroup>
    <ProjectReferences Include="WindowsApplication1\WindowsApplication1.vbproj"/>
    <ProjectReferences Include="ClassLibrary1\ClassLibrary1.vbproj"/>
    <ProjectReferences Include="ClassLibrary2\ClassLibrary2.vbproj"/>
  </ItemGroup>

  <Target Name="Build">

    <Message Text="Building for DebugSymbols=false" Importance="high"/>
    <MSBuild Projects="@(ProjectReferences)"
             Properties="DebugSymbols=false"/>

    <Message Text="Building for DebugSymbols=true" Importance="high"/>
    <MSBuild Projects="@(ProjectReferences)"
             Properties="DebugSymbols=true"/>
  </Target>

</Project>

您可以在http://www.sedodream.com/Content/binary/DebSymbols.zip下载我的文件。顺便说一句,您可能需要考虑将项目从 ProjectReference 重命名为其他内容,可能是项目 ProjectReference 具有特定含义,因此可能会造成混淆。

Sayed Ibrahim Hashimi

我的书:Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build