如何使用nuget包资源管理器同时创建带有发布和调试dll的nuget包? [英] How to create a nuget package with both release and debug dll's using nuget package explorer?

查看:202
本文介绍了如何使用nuget包资源管理器同时创建带有发布和调试dll的nuget包?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Nuget软件包资源管理器来创建一些nuget软件包。我设法做到了,只是在VS中以发布模式构建项目,然后将dll和pdb文件都添加到程序包中。

I'm using the Nuget Package Explorer to create some nuget packages. I've managed to do so just building a project in Release mode in VS and adding both the dll and pdb files to the package.

到目前为止,还不错,但是当我将包添加到另一个项目中并尝试在调试时进入代码时,它将代替它。

So far so good, but when I add the package to another project and try to step into the code while debugging, it will step over it instead.

我了解,如果我想在调试时进入代码,则需要构建Debug dll和pdb并将其添加到程序包中。我不确定如何将它们添加到我已经创建的程序包中,该程序包已经包含相同名称的Release dll和pdb文件。

I understand that I need to build and add the Debug dll and pdb to my package if I want to step into the code while debugging. I'm not sure though how to add these to the package I've already create, which already contains the Release dll and pdb file, which are named the same.

有什么想法吗?

推荐答案

我的想法是,NuGet包装是关于约定的很多内容。

My thoughts are, NuGet packaging is a lot about conventions.

为不同平台打包相同的名称空间和名称没有问题(如 lib / net40 / mydll) .dll lib / net35 / mydll.dll 等),因为NuGet会按平台过滤注册的依赖项。

There is no problem in packaging same namespaces and same names for different platforms (as in lib/net40/mydll.dll, lib/net35/mydll.dll etc in the same package), as NuGet will filter registered dependencies by platform.

为同一平台构建多个版本似乎非常规此讨论倾向于按每次构建一个软件包。这并不意味着您不能这样做,但是您应该首先问自己是否应该这样做。

Building several versions for the same platform seems unconventional, this discussion is biased towards making a package per build. That doesn't mean you can't do it, but you should first ask yourself if you should.

也就是说,如果您的调试版本与发行版版本非常不同(有条件的编译等),这可能会很有用。但是最终用户在安装软件包时将如何选择发布或调试?

That said, if your debug and release builds are very different (conditional compiling etc) this might useful though. But how will end-users choose Release or Debug when installing your package?

一个想法可能是,每个构建配置一个版本。 两者都可以安装进入项目。为此,请添加将文件定位到您的软件包或构建 一个Powershell安装脚本 (由于 Nuget v3 )直接在目标项目文件中添加条件引用(如果您想要的基础知识不如MsBuild所能实现的

An idea could be, one version per build configuration. Both can be installed into the project. To do that, either add a targets file to your package or build a powershell install script (unsupported since Nuget v3) that adds conditional references directly in the target project file, if you want something less basic than whatever MsBuild can do for you.

第一个策略的示例:创建一个.target文件(在您的程序包中,创建一个 build 文件夹,然后使用以下内容创建 build\YourLib.targets ):

Example of the first tactic: Create a .target file (in your package, create a build folder and then create build\YourLib.targets with the following contents):

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Condition="'$(Configuration)' == 'Debug'">
    <Reference Include="YourLib">
      <HintPath>..\packages\YourLib.1.0.0\lib\Debug\YourLib.dll</HintPath>
    </Reference>
  </ItemGroup>

  <ItemGroup Condition="'$(Configuration)' == 'Release'">
    <Reference Include="YourLib">
      <HintPath>..\packages\YourLib.1.0.0\lib\Release\YourLib.dll</HintPath>
    </Reference>
  </ItemGroup>
</Project>

如果您创建了debug和release文件夹(platform文件夹是可选的),则构建输出将根据关于配置-提供的数据包使用者具有常规配置名称,但是您始终可以使用 $(配置)。包含等,或者将其放在自述文件包中

Providing you created debug and release folders (platform folder is optional), the build output will effectively change depending on configuration - provided packet consumers have conventional configuration names, but you could always extend the condition logic a bit with $(Configuration).Contains etc or just put that in the package readme

这篇关于如何使用nuget包资源管理器同时创建带有发布和调试dll的nuget包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆