Dependency injection IoC:ProjectReference,ReferenceOutputAssembly=false,但仍然需要nuget包
背景 我希望将dll从我的数据访问层复制到我的应用层,以便AutoFac加载dll,但是我不希望有项目引用,这样开发人员就不会意外地直接引用和使用数据访问层类 问题 我的应用层csproj文件中有类似的内容 这一直工作得很好,但我现在意识到它没有复制瞬态依赖项,即nuget包Dependency injection IoC:ProjectReference,ReferenceOutputAssembly=false,但仍然需要nuget包,dependency-injection,.net-core,msbuild,nuget,autofac,Dependency Injection,.net Core,Msbuild,Nuget,Autofac,背景 我希望将dll从我的数据访问层复制到我的应用层,以便AutoFac加载dll,但是我不希望有项目引用,这样开发人员就不会意外地直接引用和使用数据访问层类 问题 我的应用层csproj文件中有类似的内容 这一直工作得很好,但我现在意识到它没有复制瞬态依赖项,即nuget包 <ProjectReference Include="..\MyProj.csproj"> <!-- We don't wish a developer to accidentally referen
<ProjectReference Include="..\MyProj.csproj">
<!-- We don't wish a developer to accidentally reference the DAL tier directly in the UI, only as a dependency. -->
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
<!-- As the composite root (in DI terms) we still want to ensure that the UI tier has a copy of the DAL dll to load up.-->
<OutputItemType>Content</OutputItemType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<!-- DebugSymbolsProjectOutputGroup copies PDB files, but not for Visual Studio, which is still fine as Visual Studio knows how to get debugging information. -->
<Targets>Build;DebugSymbolsProjectOutputGroup</Targets>
</ProjectReference>
假的
内容
保存最新
建设;调试符号ProjectOutputGroup
以及:
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
真的
阅读大量github门票和博客,例如:
我能想到的所有组合似乎都没有模仿nuget软件包
唯一有效的方法是:
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
true
这种做法有违将数据访问层dll与应用层分开的目标。只需创建自己的自定义复制目标,即可复制所需内容。这没什么错。然后您应该能够删除上面显示的ProjectReference。谢谢,如果这样做,我很小心,那么我不会收到关于不同版本的子依赖项的任何警告?假设如果使用内置的ProjectReference技术,我会收到警告?