Search code examples
c#asp.netbatch-filepost-build

Windows batch file to deploy all the dlls in a folder to GAC


I'm working on an ASP.NET project where I've a bunch of dlls created in a folder. I need to write a cmd or bat file to take all the dlls in that folder and GACUTIL it. So how can loop all the dlls in a folder?


Solution

  • This is what I am using to deploy all sql files in a given folder, you could adjust it to act on dll files if needs be;

    @echo off
    
    SET dbodir=../Schema Objects/Schemas/dbo/Programmability/Stored Procedures/
    SET tpmdir=../Schema Objects/Schemas/TPM/Programmability/Stored Procedures/
    
    echo --- Starting dbo schema
    
    for %%f in ("%dbodir%*.sql") do (echo Running %%f.... && @sqlcmd -U %1 -P %2 -S %3 -d %4 -i "%dbodir%%%f")
    
    echo --- Completed dbo schema
    
    echo --- Starting TPM schema
    
    for %%g in ("%tpmdir%*.sql") do (echo Running %%g.... && @sqlcmd -U %1 -P %2 -S %3 -d %4 -i "%tpmdir%%%g")
    
    echo --- Completed TPM schema
    
    pause