不使用 Visual Studio 编译 .vbproj 或 .csproj 项目文件
有没有办法像 Visual Studio 一样直接编译 .vbproj 或 .csproj 项目文件?
当您在 Visual Studio 中编译时,“输出”窗口显示对编译器的实际调用,通常如下所示:
vbc.exe [一堆选项] [looooong .vb 文件列表]
我想以编程方式调用“某物”这将采用 .vbproj 文件并执行 Visual Studio 执行的任何操作来生成这个长命令行。 我知道我可以自己解析 .vbproj 并生成该命令行,但我宁愿自己省去所有逆向工程和试错...
有没有工具可以做到这一点? 我宁愿能够在没有安装 Visual Studio 的计算机上完成此操作。 但是,如果有一种方法可以使用一些参数来调用 Visual Studio 来执行此操作,那么也可以。
我简单地查看了 MSBuild,看起来它可以在我必须特别制作的 .proj 项目文件中工作,并且每次将文件添加到 .vbproj 文件时都需要更新。 (我确实简单地看了一遍,所以很可能我错过了一些重要的东西)
任何帮助将不胜感激
Is there a way to compile a .vbproj or .csproj project file directly, just like Visual Studio does?
When you compile in Visual Studio, the "output" window shows the actual call to the compiler, which normally looks like:
vbc.exe [bunch of options] [looooong list of .vb files]
I would like to programatically call "something" that would take the .vbproj file and do whatever Visual Studio does to generate this long command line. I know i could parse the .vbproj myself and generate that command line, but I'd rather save myself all the reverse engineering and trial-and-error...
Is there a tool to do this? I'd rather be able to do it in a machine without having Visual Studio installed. However, if there's a way to call Visual Studio with some parameters to do it, then that'll be fine too.
I looked briefly at MSBuild, and it looks like it works from a .proj project file that i'd have to make especially, and that I'd need to update every time I add a file to the .vbproj file. (I did look briefly at it, so it's very likely I missed something important)
Any help will be greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
MSBuild 是最简单的方法。 例如:
MSBuild is the easiest way to go. For instance:
MSBuild 还可以获取您的解决方案文件并使用它来进行编译。
MSBuild can also take your solution file and use it to do the compile.
您可以使用 MSBUILD 或 CSC。 正如您所提到的,MSBuild 确实使用您的项目和解决方案文件。 CSC将编译特定文件,或特定目录树中的所有文件。
您还应该考虑使用 NAnt 和/或 CruiseControl.net 自动化构建。
另外,这里有一个关于如何在没有 Visual Studio 的情况下使用 CSC 编译代码的示例。
http://blog.slickedit.com/?p=163
You can use either MSBUILD or CSC. MSBuild, which as you mentioned, does use your project and solution files. CSC will compile specific files, or all files in a specific directory tree.
You should also look at automating your builds with NAnt and/or CruiseControl.net.
Also, here is an example on how to compile your code without visual studio using CSC.
http://blog.slickedit.com/?p=163
只是为了让您知道 .vbproj 和 .csproj 文件是 MSBuild。 因此,您所阅读的所有内容都可以直接应用于这些文件。
Sayed Ibrahim Hashimi
我的书:Microsoft 构建引擎内部:使用 MSBuild 和 Team Foundation Build
Just so you know .vbproj and .csproj files are MSBuild. So everything that you've read, you can apply to those files directly.
Sayed Ibrahim Hashimi
My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build
在项目解决方案文件夹中:
MSbuild通常位于:(
或类似的东西,取决于版本)
csc.exe编译文件,msbuild编译项目和解决方案
In project solution folder:
MSbuild is usually located in:
(or something similar, depending on the version)
csc.exe compiles files, msbuild compiles projects and solutions
.vbproj 文件的顶部是一个 . 将此行添加到属性组以抑制 VB 运行时:
MSBuild 会完成剩下的工作。 如果您有 IDE,则无需使用命令行。
At the top of a .vbproj file is a . Add this line to the property group to suppress the VB runtime:
MSBuild does the rest. No need to use the command line if you have the IDE.