MSbuild fails when Using MS.Extns.DependencyInjection and MS.Extns.Logging on non dotnet core project (.net fx 4.6.2) due to assembly conflicts

  • Thread starter Thread starter Aravind PK
  • Start date Start date
A

Aravind PK

Guest
I created a .net fx based asp.net web api 2 project, with which i attempted to use MS Dependency injection and MS logging assemblies from Microsoft.Extensions components. It works actually with non dotnet core based projects, providing Dependency injections and logging framework with abstractions. Locally and when we use Visual studio (ver 2017 in my case), it works, deploys if needed and runs successfully.

When we use MSBUILD though, it fails. I have another web api 2 project that is not using the DI and logging through MS.extns and it builds successfully. I have no clue to resolve the conflicts i am facing. As i try to remove the conflicting assemblies, it steps up to the Injection and logging abstraction libraries to be removed.

I am also using EF 6 in my project. The conflict started with System.ComponentModel.Annotations. My failed build log error lines are below.

both are web api 2 (non dotnet core) 1. successful build = .net fx 4.6.2, EF 6, DI using Unity. (didnt implement logging at the time) 2. failed build project = .net fx 4.6.2, EF 6, DI using MS.Extns.DI and logging using MS.Extns.Logging.

CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\AK\Api\PMApi\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.ComponentModel.Annotations.dll'. Remove one of the duplicate references. [C:\AK\Api\PMApi\PM.Data\PM.Data.csproj]
Done Building Project "C:\AK\Api\PMApi\PM.Data\PM.Data.csproj" (default targets) -- FAILED.
Done Building Project "C:\AK\Api\PMApi\PM.BL\PM.BL.csproj" (default targets) -- FAILED.
Done Building Project "C:\AK\Api\PMApi\PM.Api\PM.Api.csproj" (default targets) -- FAILED.
Done Building Project "C:\AK\Api\PMApi\ProjectManApi.sln" (default targets) -- FAILED.

Build FAILED.

"C:\AK\Api\PMApi\ProjectManApi.sln" (default target) (1) ->
"C:\AK\Api\PMApi\PM.Api\PM.Api.csproj" (default target) (2) ->
"C:\AK\Api\PMApi\PM.BL\PM.BL.csproj" (default target) (3) ->
"C:\AK\Api\PMApi\PM.Data\PM.Data.csproj" (default target) (4) ->
(CoreCompile target) ->
CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'C:\AK\Api\PMApi\packages\System.ComponentModel.Annotations.4.5.0\lib\net461\System.ComponentModel.Annotations.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.ComponentModel.Annotations.dll'. Remove one of the duplicate references. [C:\AK\Api\PMApi\PM.Data\PM.Data.csproj]

0 Warning(s)
1 Error(s)


Please help me, as i wanted to attempt DI and Logging framework using MS extns and it works cool while testing and running. As far as the msbuild goes, which i am using to setup the Continuous Integration using Jenkins/Team city as my own instance, i need MSBUILD only to build/test/deploy.

I need to know if this DI and logging from MS.Extns will not work with non dotnet core, and that i have to switch to use different DI framework. because, i have completed my api, tested locally and everything works fine.

preferrably, i wish to use these with proper advise on how to get rid of this conflict from MSBUILD.

Update: All the Nuget pkgs are latest and upto date. Also, the conflict on the Annotations is throwing in all the projects irrespective of proj that is for EF. When i have the nuget to give me libraries, why msbuild will also need to lookup Microsoft reference assemblies path in the machine drive?




Aravind

Continue reading...
 
Back
Top