[英]Error NU5012 - nuget pack unable to find path (/bin/release/MyProject/bin/release)
I'm trying to update my nuget package by running the command nuget pack -properties Configuration=Release
but this gives me the following error:我正在尝试通过运行命令nuget pack -properties Configuration=Release
来更新我的 nuget 包,但这给了我以下错误:
Unable to find 'bin/Release/{project-name}/bin/Release'.无法找到“bin/Release/{project-name}/bin/Release”。 Mae sure the project has been built确定项目已经建成
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?我不太确定为什么它会转到我的 Release 文件夹,然后继续转到另一个 Release 文件夹,因为它不存在? I'm quite lost here, and I'm not sure what to do.我在这里很迷茫,我不知道该怎么办。
TL;DR TL; 博士
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.对于新的<Project Sdk="Microsoft.NET.Sdk">
.csproj 文件格式,使用dotnet pack
构建 NuGet 包,即使它们面向 .Net Framework 或项目是多目标的。 Run this from the directory containing your .csproj
(and optionally a .nuspec
)从包含您的.csproj
(和可选的.nuspec
)的目录运行它
dotnet pack MyProject.csproj -c Release
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.请注意,默认情况下dotnet pack
将输出.nupkg
在/bin/Release
文件夹中,该文件夹与旧nuget pack
放置它的当前默认文件夹不同。
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.我建议您不要为新的.csproj
格式创建明确的.nuspec
文件,因为大多数设置都可以在新项目格式的“包”选项卡中进行设置。 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
.但是,如果您确实有.nuspec
,则dotnet pack
还将组合与项目名称匹配的任何.nuspec
文件,允许从.csproj
设置的版本和元数据中替换$
符号。
More Detail更多细节
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$
.我也遇到过这个问题 - 在以前的版本中,我通常使用这种方法来打包具有相同名称的.nuspec
文件的.csproj
,这样我就可以使用所有的 $ 令牌,如$id$
、 $version$
.
However when attempting this against the newer <Project Sdk="Microsoft.NET.Sdk">
csproj formats:但是,当针对较新的<Project Sdk="Microsoft.NET.Sdk">
csproj 格式尝试此操作时:
nuget pack {MyProject}.csproj -Prop Configuration=Release
I received the same error (note the "duplication" of bin\\release
):我收到了同样的错误(注意bin\\release
的“重复”):
Error NU5012: Unable to find 'bin\\Release{MyProject}\\bin\\Release\\'.错误 NU5012:无法找到“bin\\Release{MyProject}\\bin\\Release\\”。 Make sure the project has been built.确保项目已构建。
And if I tried packing against a .nuspec
containing symbols (NuGet Version: 4.7.1.5393)如果我尝试针对包含符号的.nuspec
打包(NuGet 版本:4.7.1.5393)
nuget pack {MyProject}.nuspec -Prop Configuration=Release
I just get the unhelpful message because nuget isn't able to resolve the $ tokens automatically.我只是收到了无用的消息,因为 nuget 无法自动解析 $ 令牌。
Value cannot be null or an empty string.值不能为 null 或空字符串。 Parameter name: value参数名称:值
However, by using dotnet pack instead of nuget但是,通过使用 dotnet pack 而不是 nuget
dotnet pack MyProject.csproj -c Release
I get to where I want to be, ie 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 eg 7zip and examining the final .nuspec
file in the package root)我到达了我想要的地方,即一个多目标的 NuGet 包,其中.nuspec
的 $ 符号与.csproj
正确同步(您可以通过打开 7zip 中的.nupkg
文件并检查最终的.nupkg
文件来验证这一点) .nuspec
包根目录中的.nuspec
文件)
I had the same problem on a multi-targeted project (targetting both net452 and netstandard2.0).我在一个多目标项目(同时针对 net452 和 netstandard2.0)上遇到了同样的问题。
My fix/hack was to add 'TargetFramework=net452' to the list of properties passed to Nuget, and manually adding the netstandard2.0-output to the files-section in the .nuspec-file我的修复/黑客是将“TargetFramework=net452”添加到传递给 Nuget 的属性列表中,并手动将 netstandard2.0-output 添加到 .nuspec-file 中的 files-section
Hope someone finds a better solution希望有人找到更好的解决方案
Part of Rune's answer (setting TargetFramework=net471
NuGet property) Rune 的部分答案(设置TargetFramework=net471
NuGet 属性)
and using NuGet version 4.9.1 (instruction here: https://stackoverflow.com/a/53614798/1813219 )并使用 NuGet 版本 4.9.1(此处的说明: https : //stackoverflow.com/a/53614798/1813219 )
was a way to go for me.对我来说是一种方式。
Actually I just solved the problem on my end.其实我只是解决了我的问题。 Nuget may not find hidden dll. Nuget 可能找不到隐藏的 dll。 Here is my solution:这是我的解决方案:
Build the project;构建项目;
Show all files in visual studio so you can see the hidden files, so that you can see the dll under bin folder;在visual studio中显示所有文件,以便您可以看到隐藏的文件,以便您可以看到bin文件夹下的dll;
Right click, open folder in file explorer, then copy it to current folder let them replace/ Or unhidden the files;右键单击,在文件资源管理器中打开文件夹,然后将其复制到当前文件夹让它们替换/或取消隐藏文件;
Do "Nuget Pack" again.再做一次“Nuget Pack”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.