.net 使用SvcUtil.exe/reference引用文件夹中的所有DLL
我们有一堆第三方DLL,它们具有我们想要使用的数据契约。现在,我们正在使用svcutil.exe分别为每个dll指定/reference来生成代理。这很乏味。是否有一种方法可以使用通配符符号来指定所有DLL。您可以使用PowerShell实现这一点,大致如下:.net 使用SvcUtil.exe/reference引用文件夹中的所有DLL,.net,svcutil.exe,.net,Svcutil.exe,我们有一堆第三方DLL,它们具有我们想要使用的数据契约。现在,我们正在使用svcutil.exe分别为每个dll指定/reference来生成代理。这很乏味。是否有一种方法可以使用通配符符号来指定所有DLL。您可以使用PowerShell实现这一点,大致如下: $endpoint = 'http://endpoint.svc?wsdl' $namespace = 'MyNamespace.Other' $generatedClassPath = 'C:...MyClass.cs' $librai
$endpoint = 'http://endpoint.svc?wsdl'
$namespace = 'MyNamespace.Other'
$generatedClassPath = 'C:...MyClass.cs'
$librairiesDirectory = 'C:path-to-dlls'
$svcUtilArgs = @(
"/t:code"
"$endpoint"
"/n:`"*,$namespace`""
"/out:`"$generatedClassPath`""
"/noconfig")
$existingLibraries = Get-ChildItem -Path "$librairiesDirectory\*.dll"
foreach ($existingLibrary in $existingLibraries) {
$svcUtilArgs += "/r:`"$existingLibrary`""
}
$svcUtilResult = (Start-Process -PassThru -FilePath SvcUtil.exe -Wait -NoNewWindow -ArgumentList $svcUtilArgs)
注意:要使其工作,您需要在路径中有SvcUtil.exe,或者需要在VS工具目录中调用vsvars32.bat