【问题标题】:How to configure a .NET Core project to copy a specified NuGet reference to the build output?如何配置 .NET Core 项目以将指定的 NuGet 引用复制到构建输出?
【发布时间】:2018-03-16 18:14:34
【问题描述】:

A 有一个 .NET Core 项目,我想将指定的 NuGet 引用 (assembly.dll) 复制到构建输出,因为我正在使用一个依赖注入组件来搜索 de bin 文件夹中的类型。

我知道我可以使用它,但是当我只想复制特定的 nuget 包时,它会复制所有的 nuget:

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
  </PropertyGroup>

【问题讨论】:

标签: c# .net-core nuget


【解决方案1】:

假设您使用的是 Visual Studio... 项目->属性->构建事件

“把它放在构建后事件命令行中:”框

copy "$(SolutionDir)assembly.dll" "$(TargetDir)"

或将其添加到您的项目文件中:

<Target Name="PostBuild" AfterTargets="PostBuildEvent">
    <Exec Command="copy &quot;$(SolutionDir)assembly.dll&quot; &quot;$(TargetDir)&quot;" />
  </Target>

【讨论】:

  • 这可行,但它不是完美的解决方案,因为每次将 nuget 更新到新版本时,我都必须更新 postbuild cmd。
猜你喜欢
  • 2017-10-05
  • 1970-01-01
  • 2017-08-09
  • 2019-12-23
  • 2018-10-08
  • 2022-07-28
  • 2021-03-10
  • 1970-01-01
  • 2020-06-22
相关资源
最近更新 更多