有没有办法发布 .NET 标准库而不在 Visual Studio 2019 中生成 .nupkg? [英] Is there a way to publish a .NET Standard Library without producing a .nupkg in Visual Studio 2019?

查看:36
本文介绍了有没有办法发布 .NET 标准库而不在 Visual Studio 2019 中生成 .nupkg?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的理解是,当您发布 .NET 标准库时,预期行为是生成 .nupkg.

My understanding is that when you publish a .NET Standard Library, the expected behavior is to produce a .nupkg.

我有内部 .Net Standard 库,我维护这些库以用于内部项目.典型的工作流程是发布库,然后将发布的文件复制到使用项目.这不是我应该做的事情吗?发布 .NET 标准库时缺少选项让我有点困惑——因为有一个 .nupkg 没有选择以不同的形式发布.

I have internal .Net Standard libraries that I maintain for use on in-house projects. A typical workflow would be to publish the libraries and then copy the published files to consuming projects. Is this not the way I should be doing things? I'm a bit confused by the lack of options when publishing a .NET Standard Library -- being that there is a .nupkg without a choice to publish in a different form.

想要从发布中得到的只是发布目录中必要的库文件的集合(不在nupkg中).有没有办法做到这一点?

What I want to get from publish is just a collection of necessary library files in the publish directory (not inside a nupkg). Is there a way to do this?

推荐答案

我的理解是,当您发布 .Net 标准库时,预期行为是生成 .nupkg.我想从中得到什么发布只是发布中必要库文件的集合目录(不在 nupkg 内).有没有办法做到这一点?

My understanding is that when you publish a .Net Standard Library, the expected behavior is to produce a .nupkg. What I want to get from publish is just a collection of necessary library files in the publish directory (not inside a nupkg). Is there a way to do this?

对于普通的 .net 框架项目,如果您引用一个 nuget 包并构建它.然后你会得到一个包含 Project.dll 和 Package.dll 的输出文件夹(bindebug 或 bin elease).这就是你想要的.

For normal .net framework projects, if you reference one nuget package and build it. You then get a output folder(bindebug or bin elease) with the Project.dll and Package.dll in it. And that's what you want.

但是对于.net标准项目,默认只会输出Project.dll.这也是预期的行为,请参阅 comment1comment2.这就是为什么我建议您需要手动编辑 xx.csproj 以在构建期间获得预期的行为.这是设计使然,它不会将 nuget 依赖项复制到输出,并且是可能满足您需求的解决方法.

But for .net standard project, it will only output the Project.dll by default. Also it's intended behavior, see comment1, comment2. And that's why I suggest you need to manually edit the xx.csproj to get your expected behavior during build. That's by design that it won't copy the nuget dependencies to output, and this is the workaround that may meet your needs.

至于为什么在VS IDE(.net标准项目)中右键项目节点=>Publish时publish输出是xx.nupkg,请查看本文档:主要分发工具.NET Standard 参考程序集是 NuGet 包.我认为这就是为什么 Publish 的输出是 xx.nupkg,很难说,但它可能是设计使然...

As for why the publish output is a xx.nupkg when you right-click project node=>Publish in VS IDE(.net standard project), please check this document:The primary distribution vehicle for the .NET Standard reference assemblies is NuGet packages. I assume that's why the output of Publish is a xx.nupkg, hard to say but, it could be by design...

有没有办法发布一个 .Net 标准库而不产生一个Visual Studio 2019 中的 .nupkg?

Is there a way to publish a .Net Standard Library without producing a .nupkg in Visual Studio 2019?

如果您指的是 .net 标准项目的发布选项.(在解决方案资源管理器中右键单击 .net 标准项目的项目名称=> 发布).恐怕答案是否定的.此选项是设计使然,目前不支持其他选项,例如发布包含所有引用程序集的文件夹.您可能需要在 DC 中添加功能请求.

If you're referring to the Publish option for .net standard project.(Right click the project name of .net standard project in Solution Explorer=>Publish). I'm afraid the answer is negative. This option is by design and for now no other options like publish a folder with all referenced assemblies are supported. You may need to add a Feature Request in DC.

希望我的澄清能有所帮助,如果我有任何误解,请随时纠正我:(

Hope my clarifications make some help and if I misunderstand anything, feel free to correct me :(

这篇关于有没有办法发布 .NET 标准库而不在 Visual Studio 2019 中生成 .nupkg?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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