Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top