简体   繁体   English

在没有Visual Studio的情况下编译.vbproj或.csproj项目文件

[英]Compiling a .vbproj or .csproj project file without Visual Studio

Is there a way to compile a .vbproj or .csproj project file directly, just like Visual Studio does? 有没有办法直接编译.vbproj或.csproj项目文件,就像Visual Studio一样?

When you compile in Visual Studio, the "output" window shows the actual call to the compiler, which normally looks like: 在Visual Studio中编译时,“输出”窗口显示对编译器的实际调用,通常如下所示:

vbc.exe [bunch of options] [looooong list of .vb files] vbc.exe [一堆选项] [looooong .vb文件列表]

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. 我想以编程方式调用“某事”来获取.vbproj文件并执行Visual Studio所做的任何操作来生成这个长命令行。 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... 我知道我可以自己解析.vbproj并生成该命令行,但我宁愿保存自己所有的逆向工程和反复试验......

Is there a tool to do this? 有没有工具可以做到这一点? I'd rather be able to do it in a machine without having Visual Studio installed. 我宁愿能够在没有安装Visual Studio的情况下在机器上完成它。 However, if there's a way to call Visual Studio with some parameters to do it, then that'll be fine too. 但是,如果有一种方法可以使用某些参数来调用Visual Studio,那么那也没关系。

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. 我简要地看了一下MSBuild,看起来它的工作原理是我必须特别制作的.proj项目文件,并且我每次将文件添加到.vbproj文件时都需要更新。 (I did look briefly at it, so it's very likely I missed something important) (我确实简要地看了一下 ,所以我很可能错过了一些重要的事情)

Any help will be greatly appreciated 任何帮助将不胜感激

MSBuild is the easiest way to go. MSBuild是最简单的方法。 For instance: 例如:

msbuild /property:Configuration=Release MyFile.vbproj

MSBuild还可以获取您的解决方案文件并使用它来进行编译。

You can use either MSBUILD or CSC. 您可以使用MSBUILD或CSC。 MSBuild, which as you mentioned, does use your project and solution files. 正如您所提到的,MSBuild确实使用了您的项目和解决方案文件。 CSC will compile specific files, or all files in a specific directory tree. CSC将编译特定目录树中的特定文件或所有文件。

You should also look at automating your builds with NAnt and/or CruiseControl.net. 您还应该考虑使用NAnt和/或CruiseControl.net自动化您的构建。

Also, here is an example on how to compile your code without visual studio using CSC. 此外,这里有一个关于如何使用CSC在没有visual studio的情况下编译代码的示例。 http://blog.slickedit.com/?p=163 http://blog.slickedit.com/?p=163

Just so you know .vbproj and .csproj files are MSBuild. 只是你知道.vbproj和.csproj文件是MSBuild。 So everything that you've read, you can apply to those files directly. 所以你读过的所有内容都可以直接应用于这些文件。

Sayed Ibrahim Hashimi Sayed Ibrahim Hashimi

My Book: Inside the Microsoft Build Engine : Using MSBuild and Team Foundation Build 我的书: Microsoft Build Engine内部:使用MSBuild和Team Foundation Build

In project solution folder: 在项目解决方案文件夹

msbuild wpfapp1.sln /p:BuildProjectReferences=true

MSbuild is usually located in: MSbuild通常位于:

C:\Windows\Microsoft.NET\Framework64\v4.0.30319

(or something similar, depending on the version) (或类似的东西,取决于版本)

csc.exe compiles files, msbuild compiles projects and solutions csc.exe编译文件,msbuild编译项目和解决方案

At the top of a .vbproj file is a . 在.vbproj文件的顶部是一个。 Add this line to the property group to suppress the VB runtime: 将此行添加到属性组以禁止VB运行时:

<NoVBRuntimeReference>On</NoVBRuntimeReference>

MSBuild does the rest. MSBuild完成剩下的工作。 No need to use the command line if you have the IDE. 如果您有IDE,则无需使用命令行。

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

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