gpt4 book ai didi

c# - Nuget包生成排除lib文件夹

转载 作者:IT王子 更新时间:2023-10-29 04:31:03 25 4
gpt4 key购买 nike

我正在尝试使用 .nuspec 文件生成 nuget 包。我们在一个屋檐下有几个项目,并试图创建 nLog.config(和转换文件)并通过 nuget 包分发它。对于任何版本的 .Net Framework,我都在寻找相同的配置文件集(只有配置没有 dll)。所以我真的不需要\lib\net45\myproject.dll 或\lib\net40\myproject.dll。虽然当我生成 nuget 包时,它总是创建 lib 文件夹并包含 dll。为与 .net Framework 版本相关的任何项目创建哪种依赖关系。

下面是我的 nuspec 文件,以防有人想引用我做错了什么。我尝试了 ""和其他一些东西,但没有运气。

<?xml version="1.0"?>
<package >
<metadata>
<id>NLogConfig</id>
<version>1.0.3</version>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>Copyright 2013</copyright>
<dependencies>
<dependency id="NLog" version="2.1.0" />
<dependency id="NLog.Schema" version="2.1.0" />
</dependencies>
</metadata>
<files>
<file src="NLog.config" target="content" />
<file src="NLog.Debug.config" target="content" />
<file src="NLog.UAT.config" target="content" />
<file src="NLog.Release.config" target="content" />
<file src="tools\*.*" target="tools"/>
</files>
</package>

如何使用 nuspec 文件(首选)或其他机制完全排除 lib 文件夹?谢谢!!

enter image description here

更新 1:

我试图偷偷摸摸,但没有成功。我放置了构建后事件并试图删除 DLL。但不知何故系统很聪明,它给了我错误“错误 79 无法找到‘C:\GITRepo\NLogConfig\NLogConfig\bin\Release\NLogConfig.dll’。确保项目已经构建。”

更新 2

我没有找到使用 .csproj 构建 nuget 包的方法,但使用外部命令并指定 nuspec 文件我能够获得相同的结果。问题仍然存在,这只是我的解决方法。

最佳答案

我想分享我的经验。我需要的是使用 csproj 作为 Nuget.exe 目标(因为我希望 NuGet 自动解析依赖项)并且结果包中没有 lib 文件夹。为了省略该文件夹,我使用了以下命令:

nuget pack <projectPath> -Exclude bin/**/*.*

关于c# - Nuget包生成排除lib文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20336807/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com