错误 NU5012 - nuget pack 无法找到路径 (/bin/release/MyProject/bin/release) [英] Error NU5012 - nuget pack unable to find path (/bin/release/MyProject/bin/release)

查看:76
本文介绍了错误 NU5012 - nuget pack 无法找到路径 (/bin/release/MyProject/bin/release)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过运行命令 nuget pack -properties Configuration=Release 来更新我的 nuget 包,但这给了我以下错误:

I'm trying to update my nuget package by running the command nuget pack -properties Configuration=Release but this gives me the following error:

无法找到bin/Release/{project-name}/bin/Release".确保项目已经建成

Unable to find 'bin/Release/{project-name}/bin/Release'. Mae sure the project has been built

我不太确定为什么它会转到我的 Release 文件夹,然后继续转到另一个 Release 文件夹,因为它不存在?我很迷茫,不知道该怎么办.

I'm not quite sure why it goes to my Release folder and then continues to go down to another Release folder as this doesn't exist? I'm quite lost here, and I'm not sure what to do.

推荐答案

TL;DR

对于新的 .csproj 文件格式,请使用 dotnet pack 以构建 NuGet 包,即使它们针对 .Net Framework 或项目是多目标的.从包含 .csproj(和可选的 .nuspec)的目录运行它

For the new <Project Sdk="Microsoft.NET.Sdk"> .csproj file format, use dotnet pack to build NuGet packages, even if they target .Net Framework or if the project is multi-targeted. Run this from the directory containing your .csproj (and optionally a .nuspec)

dotnet pack MyProject.csproj -c Release

注意默认情况下dotnet pack将输出.nupkg放在/bin/Release文件夹中,与当前默认不同旧 nuget pack 放置它的文件夹.

Note that by default dotnet pack places the output .nupkg in the /bin/Release folder, which is different from the current default folder where older nuget pack placed it.

我建议您不要为新的 .csproj 格式创建显式的 .nuspec 文件,因为大多数设置都可以在新项目格式.但是,如果您确实有 .nuspec,则 dotnet pack 还将组合与项目名称匹配的任何 .nuspec 文件,从而允许 .nuspeccode>$ 符号替换来自 .csproj 中设置的版本和元数据.

I would suggest you don't create explicit .nuspec files for the new .csproj formats, since most settings can be set in the "Packages" tab of the new Project format. However, if you do have a .nuspec, then dotnet pack will also combine any .nuspec file matching the project name, allowing for the $ symbol substitution from the version and metadata set in your .csproj.

更多细节

我也遇到过这个问题 - 在以前的版本中,我通常使用这种方法来打包<​​code>.csproj 与同名的 .nuspec 文件,这样我就可以使用所有的 $ 标记,如 $id$, $version$.

I also experienced this problem - in previous versions, I typically use to use this approach to pack against a .csproj with the .nuspec file of the same name, so that I can use all of the $ tokens like $id$, $version$.

但是,当针对较新的 <Project Sdk="Microsoft.NET.Sdk"> csproj 格式尝试此操作时:

However when attempting this against the newer <Project Sdk="Microsoft.NET.Sdk"> csproj formats:

nuget pack {MyProject}.csproj -Prop Configuration=Release

我收到了同样的错误(注意 bin\release 的重复"):

I received the same error (note the "duplication" of bin\release):

错误 NU5012:无法找到bin\Release{MyProject}\bin\Release\".确保项目已构建.

Error NU5012: Unable to find 'bin\Release{MyProject}\bin\Release\'. Make sure the project has been built.

如果我尝试对包含符号的 .nuspec 进行打包(NuGet 版本:4.7.1.5393)

And if I tried packing against a .nuspec containing symbols (NuGet Version: 4.7.1.5393)

nuget pack {MyProject}.nuspec -Prop Configuration=Release

我刚刚收到无用消息,因为 nuget 无法解决 $自动标记.

I just get the unhelpful message because nuget isn't able to resolve the $ tokens automatically.

值不能为 null 或空字符串.参数名称:值

Value cannot be null or an empty string. Parameter name: value

但是,通过使用 dotnet pack 而不是 nuget

However, by using dotnet pack instead of nuget

dotnet pack MyProject.csproj -c Release

我到达了我想去的地方,即一个多目标的 NuGet 包,其中 .nuspec 中的 $ 符号从 .csproj 正确同步(你可以通过在例如 7zip 中打开 .nupkg 文件并检查包根目录中的最终 .nuspec 文件来验证这一点)

I get to where I want to be, i.e. a multi-targeted NuGet package with the $ symbols in the .nuspec correctly synchronized from the .csproj (you can verify this by opening up the .nupkg file in e.g. 7zip and examining the final .nuspec file in the package root)

这篇关于错误 NU5012 - nuget pack 无法找到路径 (/bin/release/MyProject/bin/release)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆