Reputation: 25
We have a bunch of 3rd party dlls which have the datacontracts we want to use. Right now we are generating the proxy using svcutil.exe by specifying /reference for each dll separately. This is very tedious. Is there a way to specify all the dlls using a wild card notation instead.
Upvotes: 0
Views: 254
Reputation: 1652
You can use PowerShell for this, something along those lines:
$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)
Note: for this to work you need to have SvcUtil.exe in your Path or you'll need to invoke vsvars32.bat
in VS tools directory.
Upvotes: 1