Structure
I have something like
(A) SharedLib
which references Nop.Web
(B) Plugin uses SharedLib
And when I build them and run Nop.Web, duplicate assembly error is thrown and can’t procceed.
When I dig a bit deeper, I found that under (B)’s build output, there’s a Plugins
folder and among all other output SharedLib
‘s binary is in it, this is where the duplication is.
Solution
So I have to reference Nop.Web
but I do not want its output in my plugin’s output.
In (A)SharedLib
Instead referencing Nop.Web
this way:
<ProjectReference Include="..\..\Presentation\Nop.Web\Nop.Web.csproj" >
We use this:
<ItemGroup>
<ProjectReference Include="..\..\Presentation\Nop.Web\Nop.Web.csproj" >
<Private>false</Private>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
In (B)
Reference SharedLib
:
<ItemGroup>
<ProjectReference Include="..\Nop.Plugin.SharedLib\Nop.Plugin.Rsc.SharedLib">
<Private>false</Private>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
<ClearPluginAssemblies Include="$(MSBuildProjectDirectory)\..\..\Build\ClearPluginAssemblies.proj" />
</ItemGroup>
And also prevent Nop.Web
‘s output to be copied:
<ItemGroup>
<ProjectReference Include="..\..\Presentation\Nop.Web\Nop.Web.csproj">
<Private>false</Private>
<CopyLocalSatelliteAssemblies>false</CopyLocalSatelliteAssemblies>
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
</ProjectReference>
</ItemGroup>
контрреволюция
嗷嗷牛逼