Home > other >  Error while trying to add docker support : Value cannot be null ... netCoreVersion
Error while trying to add docker support : Value cannot be null ... netCoreVersion

Time:06-14

I had a very simple .Net Core console app that I was using to try experiment with docker/containers. I had heard that Visual Studio had great docker support and wanted to see if I could leverage it. After creating the .Net Core from the Visual Studio Templates, I right-clicked the Project to add "Docker Support...", then when prompted for Linux vs Windows, I selected Windows and then got the following error:

An error occurred while adding Docker file support to this project.

Value cannot be null. Parameter name: netCoreVersion

I've tried various things and nothing seems to be working.

CodePudding user response:

After much troubleshooting, this is what solved my problem. The TargetFramework I was using was not being recognized by Visual Studio. I wanted to test using a Windows only build because that is my primary use case.

Right-clicking the Project Properties, the TargetFramework was .NET 6.0 but the Target OS was Windows and NOT (None).

Those 2 settings combine the csproj file to have a setting of

<TargetFramework>net6.0-windows</TargetFramework>

instead of

<TargetFramework>net6.0</TargetFramework>

The Fix

Essentially get your TargetFramework to be net6.0. You can edit raw, or just select (None) as your Target OS. You can then add the Docker File, and then reset your project back to your Target OS.

  • Related