【发布时间】:2016-06-30 09:07:01
【问题描述】:
我需要在基于 Linux 的机器上安装 NuGet。当我在 Windows 机器上使用以下命令时,它工作正常。
nuget install packages.config
但是我在linux机器上无法做到这一点,如何实现呢?
【问题讨论】:
-
看看this
我需要在基于 Linux 的机器上安装 NuGet。当我在 Windows 机器上使用以下命令时,它工作正常。
nuget install packages.config
但是我在linux机器上无法做到这一点,如何实现呢?
【问题讨论】:
一旦您按照(有点烦人的)安装步骤安装了 .Net 核心并从 https://www.microsoft.com/net/core 设置了 apt repo,您就可以这样做了:
sudo apt install nuget
并且您将在本地机器上拥有一个可以工作的 nuget:
$ cat /etc/issue
Ubuntu 16.04.1 LTS \n \l
$ nuget
NuGet Version: 2.8.7.0
usage: NuGet <command> [args] [options]
Type 'NuGet help <command>' for help on a specific command.
请注意,在撰写本文时不运行nuget update -self,因为虽然它会成功安装更新版本的 nuget,但该版本实际上不会运行。
如果你确实破坏了它,你总是可以把它吹走并重新安装:
sudo apt remove nuget
sudo apt install nuget
【讨论】:
Retrieving repository 'openSUSE-Leap-15.0-Update' metadata ...............[done] Building repository 'openSUSE-Leap-15.0-Update' cache ....................[done] Loading repository data... Reading installed packages... 'nuget' not found in package names. Trying capabilities. No provider of 'nuget' found. Resolving package dependencies...
安装单声道,然后下载 nuget:
sudo apt-get install mono-complete
wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
然后使用mono nuget.exe 运行它。
【讨论】:
/usr/lib/nuget/NuGet.exe,以便nuget 命令可以工作。那个在 Ubuntu 16.4 上看起来像这样:``` #!/bin/sh exec /usr/bin/cli /usr/lib/nuget/NuGet.exe "$@" ```
nuget apt 包在 linux 上并不能真正运行,而 exe 则适用于 windows。如果你想运行 nuget,最简单的方法是使用单声道包装器。
sudo apt-get install mono-complete
//download nuget.exe
mono nuget.exe install
【讨论】:
如果你想在 WSL2 中使用nuget,步骤如下。
通过wget https://dist.nuget.org/win-x86-commandline/latest/nuget.exe下载nuget.exe
创建一个名为 nuget 的 bash 文件:
> nuget
# Or
vi nuget
vim nuget,然后是i):# Edit the file with - make sure to add the correct path to nuget.exe file
'nuget.exe' $@ &
# Make it executable
chmod +x nuget
# Edit .bashrc
vi .bashrc
export PATH=/path/to/nuget-folder:$PATH。【讨论】:
关注Microsoft instructions for installing Nuget on Linux:
在 shell 提示符 (Bash) 处执行以下命令:
# Download the latest stable `nuget.exe` to `/usr/local/bin`
sudo curl -o /usr/local/bin/nuget.exe https://dist.nuget.org/win-x86-commandline/latest/nuget.exe
通过将以下脚本添加到适合您操作系统的文件(通常为 ~/.bash_aliases 或 ~/.bash_profile)来创建别名(Bash):
# Create as alias for nuget
alias nuget="mono /usr/local/bin/nuget.exe"
重新加载外壳。通过不带参数输入nuget 来测试安装。应显示 NuGet CLI 帮助。
【讨论】: