Compiling a .vbproj or .csproj project file withou

2020-02-26 03:38发布

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

6条回答
戒情不戒烟
2楼-- · 2020-02-26 04:11

MSBuild is the easiest way to go. For instance:

msbuild /property:Configuration=Release MyFile.vbproj
查看更多
一纸荒年 Trace。
3楼-- · 2020-02-26 04:11

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

查看更多
再贱就再见
4楼-- · 2020-02-26 04:11

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

查看更多
我只想做你的唯一
5楼-- · 2020-02-26 04:20

MSBuild can also take your solution file and use it to do the compile.

查看更多
Luminary・发光体
6楼-- · 2020-02-26 04:25

In project solution folder:

msbuild wpfapp1.sln /p:BuildProjectReferences=true

MSbuild is usually located in:

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

(or something similar, depending on the version)

csc.exe compiles files, msbuild compiles projects and solutions

查看更多
虎瘦雄心在
7楼-- · 2020-02-26 04:25

At the top of a .vbproj file is a . Add this line to the property group to suppress the VB runtime:

<NoVBRuntimeReference>On</NoVBRuntimeReference>

MSBuild does the rest. No need to use the command line if you have the IDE.

查看更多
登录 后发表回答