0

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 !!

Yugal Jindle
  • 44,057
  • 43
  • 129
  • 197

3 Answers3

3

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>
skolima
  • 31,963
  • 27
  • 115
  • 151
  • **Well,** Well its fine that it will generate only 1 exe/dll but, I figured out a better way, by calling the Vbc task from the Build target and custom compiling our code to dll, in this way - I got both exe and dll with a single project file. – Yugal Jindle Jul 20 '11 at 16:12
  • I will argue that a single project file is not better, as Visual Studio will not fully understand such setup. You might not need it now, but needlessly going against the standard is usually a bad idea. – skolima Jul 21 '11 at 12:40
1

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 !

Yugal Jindle
  • 44,057
  • 43
  • 129
  • 197
0

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?

John Dhom
  • 1,022
  • 9
  • 21