调试和发布 nuget 包本地存储库 [英] Debug and release nuget packages local repository

查看:105
本文介绍了调试和发布 nuget 包本地存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在为我们的视觉工作室项目试验 nuget.但是,我们仅(或至少主要)将 nuget 用于我们自己的外部引用,并将它们存储在本地存储库(网络共享)中.我想知道的是如何处理整个调试/发布情况.

We are experimenting with nuget for our visual studio projects. However, we only (or at least mainly) use nuget for our own external references, and we store them in a local repository (network share). What I would like to know is how to handle the whole debug/release situation.

具体(简化)情况:

我们有一个主项目,其中引用了我们自己开发的两个共享组件.这些共享组件也用在我公司的其他产品中

We have a main project that has references to two shared components that we developed ourselves. These shared components are also used in other products of our company

当我们构建主项目(azure 管道)时,我们会构建项目的调试和发布版本.但是,我们只能为每个外部引用指定一个 nuget 包.

When we build the main project (azure pipelines), we build the debug and release versions of the project. However, we can only specify a single nuget package for each external reference.

我们想要完成的是在调试构建期间使用共享组件的调试版本,以及在发布构建期间使用发布版本.然而,这些(据我所知)实际上是不同的包.

What we want to accomplish to to use the debug version of the shared components during the debug build, and the release version during the release build. However, these are (as far as I know) actually different packages.

解决这个问题的方法是什么?例如,是否有一种方法可以在单个 nuget 包中同时包含发布和调试版本?是否可以针对不同的构建配置设置使用不同的 nuget 配置?

What is the way of tackeling this issue? Is there, for instance, a way to include both the release and debug versions in a single nuget package? Is it possible to have to different nuget configurations for different build configuration settings?

我找到了Nuget 的最佳实践:调试还是发布?,但是这个主题并没有真正解决我的问题.这个线程更多地是关于是否将调试版本或发布版本发布到远程服务器的讨论.我们希望同时发布并在私有存储库中使用它们.我们无意与世界其他地方共享我们的图书馆.

I've found Best practices with Nuget: Debug or Release?, however this topic doesn't really address my issue. This thread is more a discussion about whether to publish debug or release versions to a remote server. We want to publish both and use both in a private repository. We have no intention of sharing our libraries with the rest of the world.

推荐答案

NuGet 包通常只包含一组特定目标框架的程序集.由于您发布的是要由其他用户使用的 NuGet 包,因此它并不是真正设计用于发布调试和发布版本.通常,您不会向最终用户发布应用程序的调试版本和单独的发布版本.

A NuGet package will normally hold just a single set of assemblies for a particular target framework. It is not really designed to ship a debug and release version since you are publishing the NuGet package to be consumed by other users. Normally you do not publish a debug and a separate release version of your application to end users.

您可以使用 自定义 MSBuild .targets 文件 在 NuGet 包中有自己的引用和配置信息.您可以将此 .targets 文件用作项目的扩展.它将被导入,因此您可以根据项目中定义的配置根据需要定义引用.这并不理想,但它应该可以工作.

You may be able to workaround this by using a custom MSBuild .targets file in the NuGet package that has its own references and configuration information. You can use this .targets file as an extension to your project. It will be imported so you can define the references as you need based on the configurations defined in your project. It is not ideal but it should work.

这篇关于调试和发布 nuget 包本地存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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