开发者

MSBuild Compile target to generate a dll for a class?

I have a VB 开发者_如何学运维Class and when I run :

msbuild /t:Compile

It generates the Exe for the application that contains the compiled code for the class as well.

I want to have a separate dll for my VB class in myfolder Folder.

What extra arguments do I have to pass, in order to get my dll in myfolder ?

Any help is appreciated !!


If you follow the standard Visual Studio convention for the MSBuild scripts (and you probably are), then a single .vbproj maps to a single output assembly (either .exe or .dll). The output format is set by the OutputType property. To generate two output assemblies, you'll want to create two project files, and tie them together either using a solution file (you can use Visual Studio to generate it and then use MSBuild for compiling from command line) or you can create a .proj file to bundle them. Such a bundle project would look as follows:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ItemGroup>
    <ProjectsToBuild Include="**\*proj" Exclude="$(MSBuildProjectFile)"/>
  </ItemGroup>
  <PropertyGroup>
    <Configuration>Release</Configuration>
  </PropertyGroup>
  <Target Name="Build">
    <MSBuild Projects ="@(ProjectsToBuild)"
             ContinueOnError ="false"
             Properties="Configuration=$(Configuration)">
        <Output ItemName="OutputFiles" TaskParameter="TargetOutputs"/>
    </MSBuild>
  </Target>
</Project>


This can be done by invoking the Compile Task of MSbuild.

So, Writing a task to use the VBC compiler task to compile the class to a dll will do the trick.

Rest, the default compile task will generate the exe for the main module.

That is how !


You should separate your project into 2 projects. 1) .EXE containing your main() and 2) containing all of the library classes. The .EXE project then references the .DLL project.

Rebuilding the same project twice to get a .dll and a .exe is pretty strange. Why not cleanly separate the concerns?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜