Solution to 'Value cannot be null. Parameter name: path1' with dotnet and tox

When running Python unit tests with tox, you might see the following errors:

C:\Program Files\dotnet\sdk\2.0.0\NuGet.targets(466,5): error : Value cannot be null. 
C:\Program Files\dotnet\sdk\2.0.0\NuGet.targets(466,5): error : Parameter name: path1 
System.ArgumentNullException: Value cannot be null.
Parameter name: path1
   at System.IO.Path.Combine(String path1, String path2)
   at Microsoft.DotNet.Configurer.CliFallbackFolderPathCalculator.get_DotnetUserProfileFolderPath()
   at Microsoft.DotNet.Configurer.FirstTimeUseNoticeSentinel..ctor(CliFallbackFolderPathCalculator cliFallbackFolderPathCalculator)
   at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
   at Microsoft.DotNet.Cli.Program.Main(String[] args)

That is happening because all environment variables are not passed to tox by default.

Open tox.ini and add the passenv = APPDATA ProgramFiles USERPROFILE line:

[testenv]
setenv =
    PYTHONPATH = {toxinidir}

commands = 
    python setup.py test

passenv = APPDATA ProgramFiles USERPROFILE

Rerun tox and you should be good.