如何修复由于 MsBuild 导致的 apt-get 升级错误?

如何修复由于 MsBuild 导致的 apt-get 升级错误?

我刚刚在我的系统上运行了更新,但 msbuild 包的安装出现错误。

运行后sudo apt update && sudo apt upgrade && sudo apt dist-upgrade,我收到此错误消息:

Preparing to Unpack .../msbuild_1%3a16.0+xamarinxplat.2019.05.07.15.32-0xamarin2+ubuntu1804b1_all.deb ... 
Unpacking msbuild (1:16.0+xamarinxplat.2019.05.07.15.32-0xamarin2+ubuntu1804b1) over (1:16.0+xamarinxplat.2018.09.26.17.53-0xamarin3+ubuntu1804b1) ... 
dpkg: error while processing the file /var/cache/apt/archives/msbuild_1%3a16.0+xamarinxplat.2019.05.07.15.32-0xamarin2+ubuntu1804b1_all.deb (--unpack):
  trying to overwrite '/usr/lib/mono/msbuild/15.0', which is also in the package mono-roslyn 5.20.1.19-0xamarin2+ubuntu1804b1
Errors were encountered while processing:
  /var/cache/apt/archives/msbuild_1%3a16.0+xamarinxplat.2019.05.07.15.32-0xamarin2+ubuntu1804b1_all.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

我也尝试使用 进行安装sudo dpkg -i --force-depends /var/cache/apt/archives/msbuild_1%3a16.0+xamarinxplat.2019.05.07.15.32-0xamarin2+ubuntu1804b1_all.deb。然后我收到几乎相同的错误消息:

(Lendo banco de dados ... 230920 ficheiros e directórios actualmente instalados.)
A preparar para desempacotar .../msbuild_1%3a16.0+xamarinxplat.2019.05.07.15.32-0xamarin2+ubuntu1804b1_all.deb ... 
A descompactar msbuild (1:16.0+xamarinxplat.2019.05.07.15.32-0xamarin2+ubuntu1804b1) sobre (1:16.0+xamarinxplat.2018.09.26.17.53-0xamarin3+ubuntu1804b1) ... 
dpkg: erro ao processar o arquivo /var/cache/apt/archives/msbuild_1%3a16.0+xamarinxplat.2019.05.07.15.32-0xamarin2+ubuntu1804b1_all.deb (--install):
  a tentar sobre-escrever '/usr/lib/mono/msbuild/15.0', que também está no pacote mono-roslyn 5.20.1.19-0xamarin2+ubuntu1804b1
Erros foram encontrados durante o processamento de:
  /var/cache/apt/archives/msbuild_1%3a16.0+xamarinxplat.2019.05.07.15.32-0xamarin2+ubuntu1804b1_all.deb

答案1

sudo apt-get -o Dpkg::Options::="--force-overwrite" upgrade

帮我修好了

答案2

我在 Ubuntu 和 Debian 10 上都遇到过这种情况。

这个命令为我解决了这个问题:

sudo apt-get -o Dpkg::Options::="--force-overwrite" -f install

答案3

对我来说它分为两个步骤:

apt upgrade -y
sudo apt-get -o Dpkg::Options::="--force-overwrite" upgrade
sudo dpkg -i --force-depends /var/cache/apt/archives/msbuild_1%3a16.0+xamarinxplat.2019.05.07.15.32-0xamarin2+ubuntu1804b1_all.deb

相关内容