我正在尝试使用.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文件夹?谢谢!!更新1: 我试图偷偷摸摸地做,但并没有成功。我设置了后构建事件并尝试删除DLL文件。但不知何故系统很聪明,它给了我一个错误:“错误79 无法找到'C:\ GITRepo \ NLogConfig \ NLogConfig \ bin \ Release \ NLogConfig.dll'。确保已经构建了项目。”
更新2: 我没有发现用.csproj构建nuget包的方法,但是使用外部命令并指定nuspec文件,我能够达到相同的结果。问题仍然存在,这只是我的解决办法。