Migrating dotnet 1.0.3 to 2.1.2 in one single deb file


#1

Summary: I want to migrate a deb package “mypackage”, which depends on .Net 1.0.3 to the new .Net runtime 2.1.2, which is the dependency “dotnet-runtime-2.1”. My problem is, that I am not able to declare the dependency “dotnet-runtime-2.1”. Once I start the upgrade process, I will get:

apt-get upgrade mypackage
Reading package lists… Done
Building dependency tree
Reading state information… Done
You might want to run ‘apt-get -f install’ to correct these.
The following packages have unmet dependencies:
mypackage : Depends: dotnet-runtime-2.1 but it is not installed
E: Unmet dependencies. Try using -f.
The apt-get tool has access to the dotnet-runtime-2.1 and related packages, for example: apt-cache depends dotnet-runtime-2.1 dotnet-runtime-2.1 Depends: dotnet-runtime-deps-2.1 Depends: dotnet-hostfxr-2.1

The reason that apt-get denies to install dotnet-runtime-2.1 obviously is, that a dotnet 1.0.3 installation is on the system:

dpkg -l | grep dotnet
ii  dotnet-dev-1.0.3                                   1.0.3-1  amd64  .NET Core SDK 1.0.3
ii  dotnet-host                                        2.1.2-1  amd64 Microsoft .NET Core Host - 2.1.2
ii  dotnet-hostfxr-1.0.1                               1.0.1-1  amd64  Microsoft .NET Core 1.0.0 - Host FX Resolver 1.0.1
ii  dotnet-hostfxr-1.1.0                               1.1.0-1  amd64 Microsoft .NET Core 1.1.0 - Host FX Resolver 1.1.0
ii  dotnet-sharedframework-microsoft.netcore.app-1.0.4 1.0.4-1  amd64  Microsoft .NET Core 1.0.4 - Runtime Microsoft.NETCore.App 1.0.4
ii  dotnet-sharedframework-microsoft.netcore.app-1.1.1 1.1.1-1  amd64  Microsoft .NET Core 1.1.1 - Runtime Microsoft.NETCore.App 1.1.1

If I would remove manually all old dotnet packages and the old mypackage, it would be no problem to install the new mypackage with dotnet-runtime-2.1 dependency.

But I want to do it in one single deb file. Removing the old deb packages in a script, for example preinst, will fail, because the apt-get command blocks other apt-get commands. Perhaps there is a trick to get rid of the “old installation” while the mypackage deb file will be upgraded.

I made some unsuccessful experiments with “Conflicts:” and “Replaces:” For example my “control” file looks like

Package: mypackage
Version: 1.0.1
Section: web
Priority: optional
Architecture: amd64
Depends: dotnet-runtime-2.1 (= 2.1.2)
Conflicts: mypackage, dotnet-dev-1.0.3, dotnet-host, dotnet-hostfxr-1.0.1, dotnet-hostfxr-1.1.0, dotnet-sharedframework-microsoft.netcore.app-1.0.4, dotnet-sharedframework-microsoft.netcore.app-1.1.1
Replaces: mypackage, dotnet-dev-1.0.3, dotnet-host, dotnet-hostfxr-1.0.1, dotnet-hostfxr-1.1.0, dotnet-sharedframework-microsoft.netcore.app-1.0.4, dotnet-sharedframework-microsoft.netcore.app-1.1.1
Homepage: http://www.myhomepage.com
Maintainer: MyCompany Ltd
Description: the description
 .
 detailed description
 .

.NET Foundation Website | Blog | Projects | Code of Conduct