Nuget包总是使用Release文件夹

问题描述 投票:1回答:1

我正在尝试为特定的构建配置创建一个nuget包。我们以Debug为例。我运行命令:

nuget pack path_to_my.nuspec -Properties“Configuration = Debug;” - 详细程度

它抛出以下错误:

试图从'path_to_my.nuspec'构建包。 System.IO.FileNotFoundException:找不到文件:'bin \ Release \ mydll.dll'。

如您所见,它尝试从bin \ Release获取dll,而不是bin \ Debug。

是否可以告诉nuget使用与Release不同的Configuration,或使用其他路径?

nuget
1个回答
0
投票

有必要检查一下你的nuspec文件,以防万一你将释放路径硬编码到bin\Release\mydll.dll,这似乎就是这种情况。

有效的nuspec文件将引用dll而不指定环境。使用通配符允许任何环境。例如:

<?xml version="1.0" encoding="utf-8"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
  <metadata>
    <id>MyProject</id>
    <authors>iberodev</authors>
    <version>1.0.0</version>
    <projectUrl>https://www.diegodrivendesign.com/</projectUrl>
    <requireLicenseAcceptance>false</requireLicenseAcceptance>
    <description>Sample</description>
  </metadata>
  <files>
    <file src="bin\*\netstandard2.0/ProjectOne.dll" target="lib\netstandard2.0" />
    <file src="bin\*\netstandard2.0/ProjectOne.pdb" target="lib\netstandard2.0" />
    <file src="bin\*\netstandard2.0/ProjectTwo.pdb" target="lib\netstandard2.0" />
    <file src="bin\*\netstandard2.0/ProjectTwo.pdb" target="lib\netstandard2.0" />
  </files>
</package>

然后你运行nuget pack命令来引用你的nuspec。确保已编译适当环境的代码,以便nuspec引用的dll可用(例如:dotnet build --configuration Debug

nuget pack ./*NuGet/*.nuspec -Version 1.0.0 -OutputDirectory foo -Prop Configuration=Debug -Verbosity detailed
© www.soinside.com 2019 - 2024. All rights reserved.