Windows批处理文件将文件夹中的所有dll部署到GAC

发布于 2024-11-16 08:22:44 字数 108 浏览 2 评论 0原文

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

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

╰◇生如夏花灿烂 2024-11-23 08:22:44

这就是我用来部署给定文件夹中所有 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

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
羅雙樹 2024-11-23 08:22:44

如果有人正在寻找 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)
 }

If anybody is looking for the powershell way of doing it.

[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)
 }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文