Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/github/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
.net 使用SvcUtil.exe/reference引用文件夹中的所有DLL_.net_Svcutil.exe - Fatal编程技术网

.net 使用SvcUtil.exe/reference引用文件夹中的所有DLL

.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

我们有一堆第三方DLL,它们具有我们想要使用的数据契约。现在,我们正在使用svcutil.exe分别为每个dll指定/reference来生成代理。这很乏味。是否有一种方法可以使用通配符符号来指定所有DLL。

您可以使用PowerShell实现这一点,大致如下:

$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