简体   繁体   English

如何用vim构建或编译VS2010 / XNA4项目?

[英]How to build or compile VS2010/XNA4 projects with vim?

I've played with a few different plugins to get C# to compile in vim, namely Visual_studio.vim , vim-csharp and vim-csharp , but the only one that even starts to compile is OrangeT's vim-csharp , but when I'm working on an XNA solution, all the XNA references are not found: 我玩了几个不同的插件来让C#在vim中编译,即Visual_studio.vimvim-csharpvim-csharp ,但是唯一一个甚至开始编译的是OrangeT的vim-csharp ,但是当我在在XNA解决方案上,找不到所有XNA引用:

The type or namespace name 'Xna' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

Is there anything I can do to better work with C#/XNA with vim? 有什么办法可以让我更好地使用Vim与C#/ XNA一起工作吗?

If it's relevant: Windows7x64bit VisualStudio2010 XNA4 Python2.7x64bit gVim73 如果相关: Windows7x64bit VisualStudio2010 XNA4 Python2.7x64bit gVim73

@Reacher Gilt had the right idea, and so I want to give him the answer, but my final solution was to use the msbuild.exe which I've added to my PATH at some point, and combine it with this solution to make a build.bat file and :make from that. @Reacher Gilt有正确的想法,所以我想给他答案,但我的最终解决方案是使用我在某些时候添加到我的PATHmsbuild.exe ,并将它与此解决方案结合起来制作一个build.bat文件和:make from that。

  1. in my *.sln folder I wrote a build.bat file that looks like: msbuild.exe "C:\\path\\to\\*.sln" 在我的*.sln文件夹中,我写了一个build.bat文件,如下所示: msbuild.exe "C:\\path\\to\\*.sln" *.sln msbuild.exe "C:\\path\\to\\*.sln"
  2. set makeprg=build.bat
  3. OR let &makeprg='"C:\\path with spaces\\build.bat"' if you've got spaces in the file path. let &makeprg='"C:\\path with spaces\\build.bat"'如果你有在文件路径中有空格。 That's let not set with an apostrophe and then a double quote surrounding the path, along with no slashes before the space characters. let没有set一个撇号,然后周围的道路,与之前的空格字符,没有斜线沿双引号。
  4. set errorformat=\\ %#%f(%l\\\\\\,%c):\\ %m to format the error messages. set errorformat=\\ %#%f(%l\\\\\\,%c):\\ %m以格式化错误消息。
  5. :make on a file inside that directory :make在该目录中的文件上
  6. :cl to list all the errors. :cl列出所有错误。

edit: I'm not sure why, but putting the &makeprg in your vimrc doesn't seem to do anything. 编辑:我不知道为什么,但将&makeprg放在你的vimrc中似乎没有做任何事情。 Hopefully someone can explain it to me. 希望有人可以向我解释。 You have to "manually" enter it in: yy switch to current file <CR>0<Bksp><CR> 您必须“手动”输入它: yy切换到当前文件<CR>0<Bksp><CR>

You're on Windows, so you always have the option to build on the commandline with msbuild. 您在Windows上,因此您始终可以选择使用msbuild在命令行上构建。 I'm sure you have the facility in vim to run a macro specifying a project relative to the current buffer's path. 我确信你在vim中有设施运行一个宏来指定一个相对于当前缓冲区路径的项目。

The command line looks like 命令行看起来像

C:\Windows\Microsoft.NET\Framework\(version)\msbuild.exe "project file path"

This should pull in your project's references when building, so you'll avoid those errors. 这应该在构建时引入项目的引用,因此您将避免这些错误。

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

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