简体   繁体   English

在我的构建输出中包含Nuget依赖项?

[英]Include Nuget dependencies in my build output?

I am building a modular .NET core application that can load extensions at runtime using MEF. 我正在构建一个模块化的.NET核心应用程序,它可以在运行时使用MEF加载扩展。 I have 2 projects, one is a library that I want to be able to load at runtime, then I have my main application that will do the loading. 我有2个项目,一个是我希望能够在运行时加载的库,然后我有我的主应用程序将进行加载。

My library project has some Nuget dependencies. 我的库项目有一些Nuget依赖项。 In order to load my library at runtime, I need those Nuget dependencies to be available next to the library at runtime, but building using VS2017 does not include these Nuget DLLs as part of the output. 为了在运行时加载我的库,我需要在运行时在库旁边使用这些Nuget依赖项,但使用VS2017构建不包括这些Nuget DLL作为输出的一部分。

How do I get Nuget DLLs included when I build my library? 在构建库时如何获取Nuget DLL?

Edit: I have tried dotnet publish and dotnet pack , but both of those make me a nupkg file only containing my DLL and not the nuget DLLs I need with it. 编辑:我已经尝试过dotnet publishdotnet pack ,但这两个都让我成为一个只包含我的DLL而不是我需要的nuget DLL的nupkg文件。 Also, I can't load a nupkg file at runtime very easily, which is why I'd like to just get the resulting assemblies themselves on their own. 另外,我无法在运行时非常轻松地加载nupkg文件,这就是为什么我只想自己获得生成的程序集。

For what it's worth, this is what my csproj looks like: 对于它的价值,这就是我的csproj的样子:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <AssemblyName>JSON.plugin</AssemblyName>
    <IncludeBuiltProjectOutputGroup>true</IncludeBuiltProjectOutputGroup>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.Composition" Version="1.0.31" />
    <PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\..\BDDGen.Types\BDDGen.Types.csproj" />
  </ItemGroup>

</Project>

为了使构建过程将所有引用的dll文件从缓存文件夹中的NuGet包复制到构建输出中,请在<PropertyGroup>设置此属性:

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM