简体   繁体   English

无法在.net核心中发布二进制文件

[英]Unable to publish binaries in .net core

I am trying to self host a .net core MVC application. 我试图自己托管一个.net核心MVC应用程序。 It is working fine with all .cs files. 它适用于所有.cs文件。 When I published it ( dotnet publish -f netcoreapp1.0 -c release ) through command window it is shows the following error: 当我通过命令窗口发布它( dotnet publish -f netcoreapp1.0 -c release )时,它显示以下错误:

No executable found matching "bower" 找不到匹配“bower”的可执行文件

and I even tried publishing with VS. 我甚至尝试用VS发布。 It generates the binaries. 它生成二进制文件。 But when I do dotnet run in command prompt it I get this error message: 但是,当我在命令提示符下dotnet run时,我收到此错误消息:

project file does not exist 'project.json' 项目文件不存在'project.json'

Can anyone suggest how to do self hosting with binaries? 任何人都可以建议如何使用二进制文件进行自托管?

在此输入图像描述

在此输入图像描述

When running the dotnet publish command from the command-line, you have to make sure that your path variable contains all the relevant locations. 从命令行运行dotnet publish命令时,必须确保路径变量包含所有相关位置。

If you do a publish command from within Visual Studio, and look at the output in the "Build" window, you will notice that it updates the path variable before running the publish command: 如果从Visual Studio中执行发布命令,并查看“Build”窗口中的输出,您会注意到它在运行publish命令之前更新了路径变量:

在此输入图像描述

From the command line, you can accomplish this by doing something like SET Path=%PATH%;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Web\\External; 从命令行,您可以通过执行类似SET Path=%PATH%;C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\Web\\External; be

In PowerShell you can set it as 在PowerShell中,您可以将其设置为

$env:path += ";C:\Program Files (x86)\Microsoft Visual Studio 14.0\Web\External;"

You can also look at this GitHub issue: No executable found matching command "bower" 您还可以查看此GitHub问题: 找不到匹配命令“bower”的可执行文件

As for your dotnet run question, you have to execute this command in the same directory that contains the project.json file, or use the -p|--project option to specify the location of the project file. 至于你的dotnet run问题,你必须在包含project.json文件的同一目录中执行此命令,或使用-p|--project选项指定项目文件的位置。 Type dotnet run --help on the command-line for more info. 在命令行中键入dotnet run --help以获取更多信息。

I ran into this issue on an Ubuntu box and this was the fix: 我在Ubuntu盒子上遇到了这个问题,这就是修复:

npm install -g bower
npm install -g gulp

I found the fix here: https://github.com/dotnet/cli/issues/3293#issuecomment-222993063 我在这里找到了解决方法: https//github.com/dotnet/cli/issues/3293#issuecomment-222993063

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

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