【发布时间】:2017-04-18 07:53:38
【问题描述】:
我有一个an ASP.NET Core application,它是在 Windows 10 上使用 Visual Studio 2017 创建的。它可以按预期运行以下命令
cd src
dotnet restore
dotnet build
cd Hello.Portal
dotnet run
有关详细信息,请参阅存储库中的 build.cmd。
我的下一个目标是为 RHEL 7 创建一个 build.sh,它最终会生成一个 RPM(但这超出了本问题的范围)。为此,我做了以下准备:
- 在 VMware Workstation 中创建 RHEL 7.3 虚拟机
- 按照instructions 在VM 中安装dotnet core 1.1。
然后我在 Windows 10 上运行以下命令来创建自包含部署。
dotnet restore --runtime rhel.7-x64
dotnet publish --framework netcoreapp1.1 --runtime rhel.7-x64
然后我将输出通过 SFTP 传输到虚拟机,应用程序按预期工作。
然后我将 GIT 存储库克隆到 RHEL 虚拟机,然后运行以下命令,假设它的工作方式与在 Windows 上的工作方式相同。
cd src
dotnet restore
dotnet build
但是它失败并出现以下错误:
[werners@localhost src]$ dotnet restore
warn : The folder '/home/werners/development/hello/src' does not contain a project to restore.
[werners@localhost src]$ dotnet build
Couldn't find 'project.json' in current directory
[werners@localhost src]$
这看起来相当可疑。所以我注销并重新登录并运行以下命令:
[werners@localhost ~]$ scl enable rh-dotnetcore11 bash
[werners@localhost ~]$ dotnet --version
1.0.0-preview2-1-003176
在 Windows 上,版本返回以下内容:
S:\hello\src>dotnet --version
1.0.3
所以看起来 rh-dotnetcore11 没有最新发布的 .NET core 命令行版本。
为了验证,我以 root 身份运行以下命令。
[root@localhost ~]# yum install rh-dotnetcore11
Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager
Package rh-dotnetcore11-1.0-1.el7.x86_64 already installed and latest version
Nothing to do
使用 Red Hat Enterprise Linux 7.3 构建、测试、运行和发布使用 Visual Studio 2017 创建的 ASP.NET Core 应用程序需要遵循哪些说明? .
【问题讨论】:
-
microsoft.com/net/download/linux ;) 下载链接肯定有最新的,底部还有一个下载脚本
-
如果您使用 Visual Studio 2017 创建项目,它将使用 csproj 而不是 project.json 创建您的项目。 “dotnet --version”适用于 .NET 命令行界面 (CLI),而不适用于您的运行时或 sdk 版本。
-
CLI 版本是 SDK 版本。
-
@Tseng 不幸的是,
dotnet-install.sh没有在 RHEL 7.3 下安装,但没有进行一些更改。修复后,将安装支持 csproj 的 1.0.1 版。
标签: asp.net-core .net-core redhat