RE: The type 'SolutionComponentDefinition' already contains a definition for 'EntityLogicalName'
After many years of using CrmSvcUtil without any problems, this problem started occurring to me recently. I am using CRM Service Utility 9.1.0.52 and CRM Online.
It is rather annoying, so I made a PowerShell script to comment out duplicated properties.
Hope it will help you too:
function CommentContents
{
param (
$filePath,
$startTerm,
$startTermOffset,
$endTermOffset
)
$contents = Get-Content $filePath
#finding the line number of the searchTerm
$linenumber= $contents | select-string $startTerm -list -SimpleMatch | select-object -First 1
$startLine = $linenumber.LineNumber $startTermOffset
$endLine = $startLine $endTermOffset
for ($i = 0; $i -le ($contents.Length - 1); $i ) {
if ($i -eq $startLine) {
# Starting comment at the line.
$contents[$i] = "/*" $contents[$i]
}
if ($i -eq $endLine) {
# Adding close comment at the end of the line.
$contents[$i] = $contents[$i] "*/"
Break
}
}
Set-Content $filePath $contents
}
Write-Host "Fixing Model.cs by commenting out CustomAPIResponseProperty and CustomAPIRequestParameter properties."
Write-Host "It is recommended to shut down Visual Studio during this operation." -ForegroundColor Yellow
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$modelPath = Resolve-Path -Path "$scriptDir\Model.cs" -Relative
#change the startTerms to match the properties you are having problems with
echo "Replacing CustomAPIRequestProperty/EntityLogicalName"
CommentContents -filePath $modelPath -startTerm "/// The logical name of the entity bound to the custom API request parameter" -startTermOffset -2 -endTermOffset 16
echo "Replacing CustomAPIResponseProperty/EntityLogicalName"
CommentContents -filePath $modelPath -startTerm "/// The logical name of the entity bound to the custom API response property" -startTermOffset -2 -endTermOffset 16