tags:

views:

132

answers:

3

I have to compile multiple dlls (around 100) for my project. Each project/build will have only one source code file different. These dlls should have an index included. Like calc0023.dll

What is the easiest way to do that?

A: 

Whatever version of (visual studio??) you're using, I would definitely kick these off on the command line. The simplest possible thing that would work:

Write a script that calls each projects project / solution file using devenv.

See the msdn page on how to build using the command line.

DaveParillo
You don't need devenv. If you're using VS2005 or later, you can use MSBUILD to build vs projects from the command line.
Cheeso
A: 

If you have so much code repetition in each dll, here is what i suggest, take the code common to all DLLs and create a DLL of that code/functions. And then create rest of the DLLs which internally call the main DLL. But to have features like particular naming and order of build you would need to write the batch file. Visual studio in project options display the various commandline parameters which can assit you in building the projects.

But i dont know what particular requirement you going to address by creating so many DLLs which will make it difficult for you to manage the DLLs itself. One benefit i see if you create a common DLL with the repetive code is: If you change anything in the main code, you just need to recompile one project instead of 100 projects instead where you would have compiled 100 projects.

Kavitesh Singh
+1  A: 

a .cmd script :

for %%f in (*.cs) do (
    csc.exe /target:dll /o:outdir\%%~nf.dll %%f CommonFile.cs 
)

If all the source files are in the same directory, you would have to exclude the common file from the loop.

for %%f in (*.cs) do (
    if not %%f==CommonFile.cs (
        csc.exe /target:dll /o:outdir\%%~nf.dll %%f CommonFile.cs 
    )
)

The previous scripts name the generated DLL with the name of the unique source file. If you want to use a numeric index for the filename, then you need to introduce another variable.

setlocal enabledelayedexpansion
set count=1
for %%f in ("*.cs") do (
    if not %%f==CommonFile.cs (
        set CSTR=00!COUNT!
        set OUTFILE=Calc!CSTR:~-3!
        csc.exe /target:dll /o:outdir\!OUTFILE!.dll %%f CommonFile.cs
        set /a COUNT=!COUNT!+1
    )
)
endlocal
Cheeso
for %%f in (*.vb) do ( msbuild /p:Configuration=Debug;appname=%%~nf "MyDll.proj")
volody