You are here

Installing .NET on Wine (Linux)

Submitted by Druss on Sun, 2016-09-11 23:54

So I've been having trouble getting a Windows program to work in Wine (Windows emulator) on my Kubuntu 16.04 system. It's a simple program but one that requires .NET 3.5. Considering its simplicity, I thought that it'd work fine using just Mono and it did fire up. However, it wasn't terribly usable throwing constant errors and being very buggy. So I had to also install .NET 3.5.

I usually use PlayonLinux for these things as it comes with a nice GUI which makes things rather easy. However, even after installing .NET, the application defaulted to using Mono. And I couldn't uninstall Mono from PlayOnLinux. So I looked for a CLI solution and apparently the easier option is to install .NET using winetricks, a scripted installer that takes the hassle out of things. Now even with winetricks, I ran into a number of issues. The main one was with the following error message:

error: dotnet45 conflicts with dotnet20, which is already installed.

(I tried installing 4.5 too. But this errors crop up for other versions too.)

So after much mucking about and hair-pulling, installing .NET is as simple as running the following command:
$ WINEARCH=win32 WINEPREFIX=~/.wine35sp1 winetricks -q dotnet35sp1 corefonts

While this looks simple, it's doing a number of things.

  1. First it's setting the architecture of 32-bit. This is not required for all programs. But apparently, .NET on Wine works better with this enabled.
  2. It's then setting the Wine prefix to /home/.wine35sp1 (for example). What this does is creates a custom wine configuration in the /home/.wine35sp1 directory. This will not fuck up your other Wine installations and keeps things nice and isolated. If you have any problems, you can simply delete this entire directory and start over again.
  3. Next we run winetricks using the -q (quiet) switch. What this means is that it becomes an unattended install and will generally not require you to click through the installer. This switch is actually the most important ingredient of this whole exercise as most of the errors I ran into came about because I was clicking through shit and following prompts.
  4. Next we specify the packages we want installed, i.e. dotnet35sp1 and corefonts (a bunch of Microsoft fonts). For other versions, use a similar pattern; dotnet45 for .NET 4.5 and so on …
  5. Installation will take a while. Once installed, run your program using a similar syntax:
    $ WINEARCH=win32 WINEPREFIX=~/.wine35sp1 wine /home/Downloads/foo.exe
    Note that we are not running winetricks. We are executing wine.

There are a couple of things that you might need to keep in mind when troubleshooting:

  1. First, even though we have specified the -q switch, winetricks still requires some manual assistance. The script will exit if it needs you to do something. For example, it will ask you to download the msxml3 installer and possibly others and place them in specified directories within ~/.cache/.winetricks. One of these will require you to visit that pit of revulsion that is download.com. Be prepared. Once you've placed the files as specified, rerun the same winetricks command.
  2. The wonderful things about winetricks is that (as apparent from the directory noted above) it caches all downloaded installers. In other words, even if you run into trouble, you can simply start again without having to worry about downloading half a gig once again and fidget around while you wait.
  3. If the install fails for some reason, simply try running the command again. If that fails too, then delete the custom .wine directory that will have been created and start again. In this example's case, I'd delete the .wine35sp1 directory.

Hope this helps. Good luck :)