How to build a VS2010 C++ Project on a BuildServer

2019-03-20 01:47发布

问题:

I've a .NET Solution with a managed C++ assemlby Targeting .NET 3.5 created with VS2010. The command:

%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe MyProject.sln

compiles the solution on my dev machine.

On my BuildServer I get this error:

Build FAILED.

"F:\CruiseControl.NET\Projects\MyProject\MyProject.sln" (default target) (1) -> "F:\CruiseControl.NET\Projects\MyProject\MyProject\MyProject.csproj" (default target) (2) -> "F:\CruiseControl.NET\Projects\MyProject\MyProjectMAPIHelper\MyProjectMAPIHelper.vcxproj" (default target) (3) ->
F:\CruiseControl.NET\Projects\MyProject\MyProjectMAPIHelper\MyProjectMAPIHelper.vcxproj(23,3): error MSB4019: The imported project "C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.Default.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

0 Warning(s)
1 Error(s)

On my dev machine the claimed file

"C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\Microsoft.Cpp.Default.props"

exists. On my build server not.

When I try to copy this files (and all others in the same directory) other errors occurred. So this is the wrong way.

EDIT: other errors means: When I copy the file "Microsoft.Cpp.Default.props" on the build server, MSBuild is claiming other files. That shows me, that just doing a copy of missing files is not what the build environment is expecting. I am looking for an MSI/whatever package that I could install on my build server and any C++ Project will build. Installing the SDK did not the trick. Or I did something wrong during SDK installation. Or it is not possible to compile Managed C++ VS2010 Solutions just with the SDK.

I believe that "other errors" has nothing to do with my problem. My Problem is: "How do I setup my build environment correctly". /EDIT

What I've done till now:

  • I have installed the latest Win7 SDK (http://blogs.msdn.com/b/windowssdk/archive/2010/05/25/released-windows-sdk-for-windows-7-and-net-framework-4.aspx)
  • I am targeting .net 3.5
  • I've tried playing with the Platform Toolset Property - but it was just playing
  • In my solution there is a managed C++ Assembly (my Problem)
  • I am using MSBuild 4.0 because the new VS2010 project files cannot be compiled with MSBuild 3.5
  • I am using CC.NET. compilation fails in CC.NET and on the command line. So it should not be a CC.NET issue.

Are there any tips and tricks how to configure my project properly to compile on my dev machine with VS2010 and on my build server? Is there anything more to install (except VS2010)?

Thanks, Arthur

回答1:

For now, installing VS 2010 is your only safe option. The Windows SDK will be updated to enable your scenario, but I don't have a specific release date. Until then, you'll need to install VS 2010 with the C++ tools in order to build your 2010 solution with C++ projects. Make sure you let the C++ team know about how dissatisfaction with this situation via their team blog and/or MSDN Forum.

Even after installing VS 2010, you may need to invoke the appropriate vcvars*.bat file to setup your environment variables correctly.



回答2:

Why don't you want to install VS2010 on your build server? If it's licencing, it's licenced per developer head not per install so I'm reasonably sure you are allowed to without buying another copy - or, at worst, you can install the express version which ought to at least install the config bits you're missing so you can use the platform SDK compiler.

If you're still having problems with msbuild you can then use devenv.com /build which exactly replicate the VS build env.



回答3:

You may try those links:

http://social.msdn.microsoft.com/Forums/en-US/tfsbuild/thread/9055ca52-586b-459f-9dd1-a9d052d076b9/

or

http://msdn.microsoft.com/en-us/library/ee662426.aspx