简体   繁体   English

Nuget包始终使用Release文件夹

[英]Nuget pack always using Release folder

I'm trying to create a nuget package for a specific build configuration. 我正在尝试为特定的构建配置创建一个nuget包。 Let's use Debug as an example. 让我们以Debug为例。 I run the command: 我运行命令:

nuget pack path_to_my.nuspec -Properties "Configuration=Debug;"-Verbosity Detailed nuget pack path_to_my.nuspec-属性“配置=调试;”-详细

It throws me the following error: 它引发了以下错误:

Attempting to build package from 'path_to_my.nuspec'. 尝试从“ path_to_my.nuspec”构建软件包。 System.IO.FileNotFoundException: File not found: 'bin\\Release\\mydll.dll'. System.IO.FileNotFoundException:找不到文件:“ bin \\ Release \\ mydll.dll”。

As you can see, it tries to get the dll from bin\\Release, and not bin\\Debug. 如您所见,它尝试从bin \\ Release而不是bin \\ Debug获取dll。

Is it possible to tell nuget to use a different Configuration than Release, or use another path? 是否可以告诉nuget使用与Release不同的配置,或使用其他路径?

It would be necessary to check your nuspec file just in case you have hardcoded the Release path to bin\\Release\\mydll.dll , which is seems it's the case. 以防万一您已经将Release路径硬编码到bin\\Release\\mydll.dll ,这很有必要检查nuspec文件。

A valid nuspec file would have references to the dll without specifying the environment. 一个有效的nuspec文件将在不指定环境的情况下引用dll。 Use wildcard to allow for any environment. 使用通配符可用于任何环境。 For example: 例如:

<?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>

then you run the nuget pack command to reference your nuspec. 然后您运行nuget pack命令来引用您的nuspec。 Make sure you have compiled the code for the proper environment so that the dll that the nuspec references are available (eg: dotnet build --configuration Debug ) 确保已针对适当的环境编译了代码,以便nuspec引用的dll可用(例如: dotnet build --configuration Debug

nuget pack ./*NuGet/*.nuspec -Version 1.0.0 -OutputDirectory foo -Prop Configuration=Debug -Verbosity detailed

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM