【问题标题】:Windows batch file to deploy all the dlls in a folder to GACWindows批处理文件将文件夹中的所有dll部署到GAC
【发布时间】:2011-06-20 05:38:19
【问题描述】:

我正在处理一个 ASP.NET 项目,我在一个文件夹中创建了一堆 dll。我需要编写一个 cmd 或 bat 文件来获取该文件夹中的所有 dll 并 GACUTIL 。那么如何循环一个文件夹中的所有dll呢?

【问题讨论】:

  • 使用FOR 循环。运行FOR /? 了解所有血腥细节。

标签: c# asp.net batch-file post-build


【解决方案1】:

这是我用来在给定文件夹中部署所有 sql 文件的方法,如果需要,您可以调整它以作用于 dll 文件;

@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

【讨论】:

  • 没有问题。我首先从stackoverflow得到了答案:)
【解决方案2】:

如果有人正在寻找 powershell 的方式。

[System.Reflection.Assembly]::Load("System.EnterpriseServices, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a")            
$publish = New-Object System.EnterpriseServices.Internal.Publish       

$dlls = Get-ChildItem -Path C:\Code\Application\ -Filter *dll -Recurse -ErrorAction SilentlyContinue -Force  | %{$_.FullName}

 foreach ($dll in $dlls) {
   $publish.GacInstall($dll)
 }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-12-01
    • 2013-04-12
    • 2016-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-07
    相关资源
    最近更新 更多