简体   繁体   English

开源Visual Studio项目分发的噩梦

[英]Open source Visual Studio project distribution nightmare

Every time Microsoft releases a new version of visual studio, they always require me to convert my solution and project files to 'the latest version.' 每当微软发布新版本的visual studio时,他们总是要求我将我的解决方案和项目文件转换为“最新版本”。 Even with something as simple as a "Hello World" solution, I need to go through their conversion wizard! 即使使用像“Hello World”解决方案这样简单的东西,我也需要完成他们的转换向导!

And, to make things worse, the new visual studio solution files aren't compatible with old versions of visual studio. 而且,更糟糕的是,新的visual studio解决方案文件与旧版本的visual studio不兼容。

What a nightmare for anyone working with a group of people...or anyone hoping to distribute the source code for their projects. 对于那些与一群人合作的人来说,或者任何希望为他们的项目分发源代码的人,这真是一场噩梦。

Is there any good way to distribute a visual studio project, and allowing people using older versions of visual studio to still use it? 是否有任何好方法来分发视觉工作室项目,并允许使用旧版Visual Studio的人仍然使用它? It's a simple C program, not using any nifty options. 这是一个简单的C程序,不使用任何漂亮的选项。 I only have access to Visual Studio 2008, and Visual Studio provides no backwards 'conversion' wizard. 我只能访问Visual Studio 2008,并且Visual Studio不提供向后“转换”向导。 Would it make sense to release the source code using nmake+makefile to build the program? 使用nmake + makefile发布源代码来构建程序是否有意义? It seems the nmake file format hasn't changed significantly in some time, and would be possible to provide a makefile that works with a wider range of versions of visual studio. 似乎nmake文件格式在一段时间内没有显着改变,并且可以提供适用于更广泛版本的visual studio的makefile。

The normal way to do this is to place the vs project files in a sub directories of the solution. 执行此操作的常规方法是将vs项目文件放在解决方案的子目录中。 Eg 例如

solution
 - build
 -- vc6
 -- vc7
 -- vc8
 -project1
 -- src
 -- build
 --- vc6
 --- vc7
 --- vc8
 -project2
 -- src
 -- build
 --- vc6
 --- vc7
 --- vc8

Then when you get a new version of vs - copy the last project directory eg vc7 to vc8 - do the same for the solution - open the solution and project files in a text editor to fix any paths - finally open the solution in the new version of vs and let it convert your projects - (Use source control as if one or your paths are wrong it update a project in an old directory) 然后,当您获得新版本的vs - 将最后一个项目目录(例如vc7)复制到vc8时 - 对解决方案执行相同操作 - 在文本编辑器中打开解决方案和项目文件以修复任何路径 - 最后在新版本中打开解决方案vs并让它转换你的项目 - (使用源代码控制就像一个或你的路径错误它更新旧目录中的项目)

This is tiresome but you only have to do it every few years. 这很烦人,但你每隔几年就要做一次。

This is how we used to do it, but there is a better way however and that is to use CMake to generate your projects. 这就是我们以前的做法,但是有一种更好的方法,那就是使用CMake来生成你的项目。 We use this now in work and it allows use to use a single project definition to work natively on windows and unix. 我们现在在工作中使用它,它允许使用单个项目定义在Windows和unix上本地工作。 On windows we use vs projects on unix we use eclipse and makefiles. 在Windows上,我们在unix上使用vs项目,我们使用eclipse和makefile。 Also CMake allows you to abstract common project settings like compiler and linker flags, so they only have to be modified in one place. 此外,CMake允许您抽象编译器和链接器标志等常见项目设置,因此只需在一个位置进行修改。

I now use CMake for all c++ projects whether I require its multi platform capabilities or not. 我现在将CMake用于所有c ++项目,无论我是否需要其多平台功能。

You could use CMake as the build tool for your project. 您可以使用CMake作为项目的构建工具。 It will generate VS project files for you, and you can just open the file and use it to build the project. 它将为您生成VS项目文件,您只需打开该文件并使用它来构建项目。 The conversion problems won't matter, because you can just use CMake to build it again. 转换问题无关紧要,因为您可以使用CMake再次构建它。

The advantage of CMake in this case is portability and version-independence (also cross-platform build capability, but that may not be relevant). 在这种情况下,CMake的优势是可移植性和版本独立性(也是跨平台构建功能,但这可能不相关)。 CMake does, however, have a bit of a learning curve to it and it's not quite as simple as just using a project file, but it does solve the problem you are experiencing. 然而,CMake确实有一点学习曲线,并不像使用项目文件那么简单,但它确实解决了您遇到的问题。 Since your project is relatively simple, it may be a solution for you. 由于您的项目相对简单,它可能是您的解决方案。

There is no simple answer. 没有简单的答案。 I wish we did, though. 但我希望我们做到了。 The situation is only getting worse with the fact that 2005 onwards you also need to pack in a redist pack or do a static linking with the runtime. 情况只会越来越糟,因为2005年以后你还需要打包一个redist包或者与运行时进行静态链接。 And I haven't a clue as to what it will do if you have a 2008 static-linked binary talking to a earlier generation (earlier than 2005) application. 如果你有一个2008静态链接二进制文件与前一代(早于2005年)的应用程序交谈,我就不知道它将会做什么。 According to MS, this should work. 根据MS,这应该工作。

Can you safely assume all your users will have a copy of Visual Studio? 您能安全地假设您的所有用户都拥有Visual Studio的副本吗? And are they all running the same version? 它们都运行相同的版本吗? (I know, the express edition is free nowadays...) You will need to educate your user base on the difficulties if you continue to pursue this path and have them all use the same version of VS2008 to make life easier for everyone around. (我知道,快递版现在是免费的......)如果你继续追求这条道路并且让他们都使用相同版本的VS2008让你的每个人的生活更轻松,你需要教育你的用户基础上的困难。

I would rather use make/gcc than having go round the park, though. 不过,我宁愿使用make / gcc而不是去公园。

I think using nmake is the way to go - unfortunately VC6 is the last version that would automatically create one for you based on the project. 我认为使用nmake是可行的方法 - 不幸的是,VC6是最后一个版本,可以根据项目自动为您创建一个版本。

However, you say your project is pretty simple, so this shouldn't be a major barrier. 但是,你说你的项目很简单,所以这不应该是一个主要的障碍。

I'd suggest you use the open source process. 我建议你使用开源过程。 Release your code as VS 2008, and allow someone who uses earlier versions to contribute the solution file for those versions. 将您的代码发布为VS 2008,并允许使用早期版本的人为这些版本提供解决方案文件。 That's the open source way. 这是开源方式。

One solution I have seen utilized by commercial Windows libraries is naming the solution files with the VS version as a suffix (eg: Project_VS2005.sln, Project_VS2008.sln, etc.). 我见过的商业Windows库使用的一个解决方案是将VS版本命名为后缀(例如:Project_VS2005.sln,Project_VS2008.sln等)。 You still have to keep them in sync, but you don't have to change file paths, or include directories, or modify the actual solution files much; 您仍然必须保持它们同步,但您不必更改文件路径,包含目录或修改实际的解决方案文件; just keep multiple files, one for each VS version which is supported. 只保留多个文件,每个文件对应一个支持的VS版本。 You have to do the same thing for the project files, but at least you don't have to change the contents around to support different directory structures unless you want to support building side-by-side with multiple VS versions, and in the case where you do you only have to change the output settings for each different project file. 您必须对项目文件执行相同的操作,但至少您不必更改内容以支持不同的目录结构,除非您希望支持与多个VS版本并排构建,并且在这种情况下在这里,您只需更改每个不同项目文件的输出设置。

Not saying it's a great solution, but rather just another option. 不是说这是一个很好的解决方案,而是另一种选择。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM