Search code examples
c#.netubuntuvisual-studio-code.net-8.0

I can't set up my Linux Ubuntu 20.04 environment and VS Code properly to work with C#


I built a simple project to test if everything was working correctly. However, the autocomplete, IntelliCode, and other features are not working properly. When I try to load a project, I receive the message:

Activating the "Microsoft.VisualStudio.CpsProjectIconSourceService (0.1)" service failed.

I tried clearing the cache and configuration files, reinstalling the .NET SDK, opening and closing VS Code, resetting settings, reinstalling extensions, among other things.


Solution

  • There are known issues in latest .net + vscode + c# dev kit. The github issues hints to proof the setup of .net sdk.

    There are multiple ways to setup .net 8 on ubuntu. Give this a try (known to compile .net 8 assemblies using ubuntu):

    # drops old dependencies and repos
    sudo snap remove dotnet-sdk
    sudo apt remove 'dotnet*'
    sudo apt remove 'aspnetcore*'
    sudo apt remove 'netstandard*'
    sudo apt autoremove -y
    sudo rm /etc/apt/sources.list.d/microsoft-prod.list
    sudo rm /etc/apt/sources.list.d/microsoft-prod.list.save
    
    # Get Ubuntu version
    declare repo_version=$(if command -v lsb_release &> /dev/null; then lsb_release -r -s; else grep -oP '(?<=^VERSION_ID=).+' /etc/os-release | tr -d '"'; fi)
    
    # Download Microsoft signing key and repository
    wget https://packages.microsoft.com/config/ubuntu/$repo_version/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
    
    # Install Microsoft signing key and repository
    sudo dpkg -i packages-microsoft-prod.deb
    
    # Clean up
    rm packages-microsoft-prod.deb
    
    # Update packages
    sudo apt update 
    
    # get .net 8
    sudo apt-get install -y dotnet-sdk-8.0