1

I need to integrate a legacy VS2008 project into my VS2013 solution. This project uses some custom build rules which initially worked after converting the .vcproj to a .vcxproj. However, when doing a fresh checkout of the project including the .vcxproj, the project file can no longer be opened.

I've tracked it down to this issue:

The project file references a couple of custom build rules like this:

<ImportGroup Label="ExtensionSettings">
  <Import Project="..\..\..\tools\build\ms_mc.props" />
  (8 similar lines follow)
</ImportGroup>

However, the ms_mc.props file is not present, but there is a ms_mc.rule file. If I convert the VS2008 solution with VS2013 (and assumably also if I opened it in VS2008, which I don't possess), the ms_mc.props file (plus a .targets and a .xml file) is created. However, if I delete that file and open the converted VS2013 project, the file does not get created.

I realized, in the old .vcproj, the corresponding lines are

<ToolFiles>
  <ToolFile RelativePath="..\..\..\tools\build\ms_mc.rule" />
  (8 similar lines follow)
</ToolFiles>

Why does VS2008 reference the .rule file and VS2013 imports the .props file without specifying the .rule file? And more importantly: How can I make this work again?

The .rule and .props file are added for reference


ms_mc.rule:

<?xml version="1.0" encoding="utf-8"?>
<VisualStudioToolFile
    Name="MS MC"
    Version="8,00"
    >
    <Rules>
        <CustomBuildRule
            Name="MS_MC"
            DisplayName="Microsoft Message Catalogue Compiler"
            CommandLine="mc [Verbose] [inputs] [RCIncludePath] [CIncludePath]"
            Outputs="[$RCIncludePath]\$(InputName).rc;[$RCIncludePath]\$(InputName).h"
            FileExtensions="*.mc"
            ExecutionDescription="Compiling Message Catalogue $(InputName).mc"
            >
            <Properties>
                <BooleanProperty
                    Name="Verbose"
                    DisplayName="Verbose"
                    Description="Gives verbose output. (-v)"
                    Switch="-v"
                />
                <StringProperty
                    Name="RCIncludePath"
                    DisplayName="RC include file path"
                    Description="Gives the path of where to create the RC include file and the binary message resource files it includes. (-r [pathspec])"
                    Switch="-r [value]"
                    DefaultValue=".\"
                />
                <StringProperty
                    Name="CIncludePath"
                    DisplayName="C include file path"
                    Description="Gives the path of where to create the include header file. (-h [pathspec])"
                    Switch="-h [value]"
                    DefaultValue=".\"
                />
            </Properties>
        </CustomBuildRule>
    </Rules>
</VisualStudioToolFile>

ms_mc.props (after Conversion to VS2013):

<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup
    Condition="'$(MS_MCBeforeTargets)' == '' and '$(MS_MCAfterTargets)' == '' and '$(ConfigurationType)' != 'Makefile'">
    <MS_MCBeforeTargets>Midl</MS_MCBeforeTargets>
    <MS_MCAfterTargets>CustomBuild</MS_MCAfterTargets>
  </PropertyGroup>
  <PropertyGroup>
    <MS_MCDependsOn
      Condition="'$(ConfigurationType)' != 'Makefile'">_SelectedFiles;$(MS_MCDependsOn)</MS_MCDependsOn>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <MS_MC>
      <Verbose>False</Verbose>
      <RCIncludePath>.\</RCIncludePath>
      <CIncludePath>.\</CIncludePath>
      <CommandLineTemplate>mc [Verbose] [inputs] [RCIncludePath] [CIncludePath]</CommandLineTemplate>
      <Outputs>%(RCIncludePath)\%(Filename).rc;%(RCIncludePath)\%(Filename).h</Outputs>
      <ExecutionDescription>Compiling Message Catalogue %(Filename).mc</ExecutionDescription>
    </MS_MC>
  </ItemDefinitionGroup>
</Project>
4

1 回答 1

0

我发现这篇 VS2010 的博客文章指出以下内容:

自定义构建规则是 VS2005 中引入的构建功能。它为用户提供了轻松插入第三方工具以在其构建过程中使用的能力。自定义构建规则由“.rules”文件定义。

更重要的是

在VS2010中,由于迁移到MSBuild,规则文件中的信息由三个文件表示:.XML、.props和.targets文件。

这基本上意味着 .XML、.props 和 .targets 文件实际上不是由 VS2008 创建的;相反,它们是自 VS2010 以来旧的 .rules 文件格式的替代品。使用这些信息,我现在可以安全地签入这些新文件,而不会破坏 VS2008 解决方案。我可能必须手动调整新文件才能使它们像以前一样工作,正如博客中提到的那样。

于 2015-03-06T06:24:14.010 回答