Ale*_*ith 5 msbuild dependency-injection autofac nuget .net-core
背景
我希望将 dll 从数据访问层复制到应用程序层,以便 AutoFac 加载 dll,但不希望有项目引用,以便开发人员不会意外引用和使用数据访问层直接上课。
问题
我的应用程序层 csproj 文件中有类似的内容。
这一直工作得很好,但我现在意识到它没有复制瞬态依赖项,即 nuget 包
<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>
Run Code Online (Sandbox Code Playgroud)
随着:
<PropertyGroup>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
</PropertyGroup>
Run Code Online (Sandbox Code Playgroud)
阅读大量 github 票证和博客,例如:
https://www.erikheemskerk.nl/transitive-nuget-dependency-net-core-got-your-back/
https://github.com/NuGet/Home/issues/6151
https://github.com/dotnet/sdk/issues/747
玩我能想到的所有组合,似乎并没有复制 nuget 包。
唯一有效的方法是:
<ReferenceOutputAssembly>true</ReferenceOutputAssembly>
Run Code Online (Sandbox Code Playgroud)
这违背了使数据访问层 dll 远离应用程序层的目标。
| 归档时间: |
|
| 查看次数: |
495 次 |
| 最近记录: |