How to build a VS2010 MakeFile project (vcxproj) with TFS Build (No VS 2010)

前端 未结 4 612
刺人心
刺人心 2020-12-10 03:17

I have a project that was building fine in VS 2008, and then we installed and started using TFS Build, and then we upgraded to TFS 2010. Everything was still fine and build

相关标签:
4条回答
  • 2020-12-10 03:33

    An improved alternative to BlueMonkMN is to add

    <PropertyGroup>
      <VCTargetsPath Condition="'$(VCTargetsPath)' == ''">[path_to_the_fileset_listed]</VCTargetsPath>
    </PropertyGroup>
    

    as a level 1 child near the top of the vcxproj.

    The path could include an environment variable or some other well-known path containing variable.

    This makes less of an an intrusion and is easier to revert than changing lots of lines.

    0 讨论(0)
  • 2020-12-10 03:46

    An even more simple approach with adding an environment variable for VCTargetsPath:

    1. Locate the CPP Msbuild Folder mentioned by BlueMonkMN
      • e.g. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120
    2. Open Windows environment variables
      • Control Panel > System > Advanced Settings > Advanced > Environment Variables
    3. Add a new user variable with:
      • Name: VCTargetsPath
      • Value: [your path to MsBuild targets from step 1]
    4. Restart Visual Studio.
    5. Done. Your project should build now.
    0 讨论(0)
  • 2020-12-10 03:47

    I have devised a somewhat complex, but functional work around involving the following steps.

    1. Copy these files from C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0 on a system where VS2010 is installed -- check them into source control so they are retrieved as part of the workspace:
      • Microsoft.Build.CPPTasks.Common.dll
      • Microsoft.BuildSteps.targets
      • Microsoft.Cl.Common.props
      • Microsoft.Cpp.Default.props
      • Microsoft.Cpp.props
      • Microsoft.Cpp.targets
      • Microsoft.CppBuild.targets
      • Microsoft.CppCommon.targets
      • Microsoft.Link.Common.props
      • Microsoft.MakeFile.targets
      • Platforms\Win32\Microsoft.Cpp.Win32.default.props
      • Platforms\Win32\Microsoft.Cpp.Win32.props
      • Platfotms\Win32\Microsoft.Cpp.Win32.targets
    2. Change the vcxproj file to refer to the relative path where the workspace puts those files instead of $(VCTargetsPath).
    3. Change lines (in all those files) to use attribute AssemblyFile="Microsoft.Build.CPPTasks.Common.dll" instead of referring to this using the AsssemblyName attribute.
    4. Delete "$(VCTargetsPath)\" in the files at the root of the new location so that it finds its sibling files instead of trying to refer to the non-existent VCTargetsPath macro. You can find instances that you missed by trying to run a command line build with MSBuild on the machine without VS 2010 and looking at the error messages.
    5. Similarly replace $(VCTargetsPath) in child directory files with relative paths.
    6. At the end of the file Microsoft.Cpp.Win32.targets, comment out the "<VCMessage Code="MSB8008" ... />" line and the following related <Import>.
    7. Trial and error, run command line build and see what else I may have forgotten to mention. I think that was most of it.
    0 讨论(0)
  • 2020-12-10 03:51

    The Microsoft Windows SDK 7.1 has several installation options. Having only the ".NET Development" child "Tools" checked is apparently not enough to build vcxproj projects, even if they don't include any C++ code (only pre- and post-build steps). Adding the "Visual C++ compilers" option and fully selecting the "Intellisense and Reference Assemblies" checkbox installs the necessary files and settings. I'm not sure if both are necessary, but that combination did work for me.

    0 讨论(0)
提交回复
热议问题