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

查看:641
本文介绍了有没有一种方法可以发布.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。我想从
publish获得的只是publish
目录中的必要库文件的集合(而不是在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的输出文件夹(bin\debug或bin\release)。

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

但是对于 .net standard 项目,它将仅输出 Project.dll 默认情况下。这也是预期的行为,请参见 comment1 评论2 。这就是为什么我建议您需要手动编辑 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.

当右键单击项目node => Publish in时,为什么 publish输出为xx.nupkg VS IDE(.net标准项目),请检查此文档 .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...

编辑:


是否可以在Visual Studio 2019中发布.Net标准库而不产生
.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天全站免登陆