Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.ArgumentException: '' is not a valid version string. (Parameter 'value') #28

Closed
stijnherreman opened this issue Aug 29, 2022 · 12 comments

Comments

@stijnherreman
Copy link

The extension suddenly fails to start in my devcontainer. I'm running VSCode 1.70.2 and extension version 0.4.6

Starting MSBuild language service...
Failed to start the MSBuild language server.
Error: Command failed: "/usr/bin/dotnet" "/root/.vscode-server/extensions/tintoy.msbuild-project-tools-0.4.6/out/language-server/MSBuildProjectTools.LanguageServer.Host.dll" --probe
System.ArgumentException: '' is not a valid version string. (Parameter 'value')
   at NuGet.Versioning.SemanticVersion.Parse(String value)
   at MSBuildProjectTools.LanguageServer.Utilities.DotNetRuntimeInfo.ParseDotNetVersionOutput(TextReader dotnetVersionOutput) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\DotNetRuntimeInfo.cs:line 140
   at MSBuildProjectTools.LanguageServer.Utilities.DotNetRuntimeInfo.GetCurrent(String baseDirectory, ILogger logger) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\DotNetRuntimeInfo.cs:line 69
   at MSBuildProjectTools.LanguageServer.Utilities.MSBuildHelper.DiscoverMSBuildEngine(String baseDirectory, ILogger logger) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\MSBuildHelper.cs:line 96
   at MSBuildProjectTools.LanguageServer.Program.Main() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer\Program.cs:line 39

I can retrieve the version in a terminal. Not sure how to properly debug this.

# dotnet --version
6.0.202

Dockerfile:

FROM ubuntu:21.04

RUN apt-get update \
	&& apt-get install -y curl git wget

RUN wget https://packages.microsoft.com/config/ubuntu/21.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb \
	&& dpkg -i packages-microsoft-prod.deb \
	&& rm packages-microsoft-prod.deb \
	&& apt-get update \
	&& apt-get install -y apt-transport-https \
	&& apt-get update \
	&& apt-get install -y dotnet-sdk-6.0

RUN curl -fsSL https://deb.nodesource.com/setup_17.x | bash - \
	&& apt-get install -y nodejs

RUN apt-get install -y postgresql

ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
	&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \

devcontainer.json

{
	"build": {
		"dockerfile": "Dockerfile"
	},

	"postStartCommand": "service postgresql start",

	"settings": {
		"terminal.integrated.defaultProfile.linux": "bash"
	},

	"extensions": [
		"ckolkman.vscode-postgres",
		"editorconfig.editorconfig",
		"ms-dotnettools.csharp",
		"redhat.vscode-yaml",
		"tintoy.msbuild-project-tools"
	]
}
@tintoy
Copy link
Owner

tintoy commented Aug 29, 2022

Can you try setting the environment variable MSBUILD_PROJECT_TOOLS_VERBOSE_LOGGING=1 inside the container?

If necessary, you can explicitly set it and run the language server in smoke-test mode:

MSBUILD_PROJECT_TOOLS_VERBOSE_LOGGING=1 MSBUILD_PROJECT_TOOLS_LOG_FILE=/root/language-server.log "/usr/bin/dotnet" "/root/.vscode-server/extensions/tintoy.msbuild-project-tools-0.4.6/out/language-server/MSBuildProjectTools.LanguageServer.Host.dll" --probe.

That should log the full output from attempting to run dotnet --version and some additional diagnostic info to /root/language-server.log.

@stijnherreman
Copy link
Author

I've tried the second option, but no log file is created. I've also tried making it write to /workspaces/myproject without success.

The first option requires rebuilding the container I think, should I go ahead and try that?

@tintoy
Copy link
Owner

tintoy commented Aug 29, 2022

Yeah - if we can’t get any output it’s making me wonder whether it’s having some other problem launching the dotnet host to discover its version (literally the command dotnet --version). I’m off to bed (sorry it’s been a looong day) but I’ll come back to have a proper think about it tomorrow.

@tintoy
Copy link
Owner

tintoy commented Aug 29, 2022

(according to the error message, dotnet --version produced no output)

@stijnherreman
Copy link
Author

I've done a rebuild with the env var set, but no log file is created.

	"containerEnv": {
		"MSBUILD_PROJECT_TOOLS_VERBOSE_LOGGING": "1"
	},

On the first launch after the rebuild, the extension started fine. I then stopped the container and restarted it through VSCode, this time the extension hanged at Starting MSBuild language service.... Stopped and restarted again, now I had the error.

@tintoy
Copy link
Owner

tintoy commented Aug 29, 2022

I’ll try to set up the same dev container tomorrow and see what I can find by poking around :)

@tintoy
Copy link
Owner

tintoy commented Aug 30, 2022

Am trying this out now. For what it's worth, I can't get the container to build for ubuntu:21.04 (apt complains that some package repos are returning 404/NotFound) so I'm targeting ubuntu:22.10 instead.

Will let you know what I find.

tintoy added a commit that referenced this issue Aug 30, 2022
tintoy added a commit to tintoy/msbuild-project-tools-vscode that referenced this issue Aug 30, 2022
@tintoy
Copy link
Owner

tintoy commented Aug 30, 2022

Published v0.4.7 of the extension (may take a little while to show up in the gallery). If you then go into your dev container and run:

MSBUILD_PROJECT_TOOLS_VERBOSE_LOGGING=1 MSBUILD_PROJECT_TOOLS_LOGGING_TO_STDERR=1 "/usr/bin/dotnet" "/root/.vscode-server/extensions/tintoy.msbuild-project-tools-0.4.6/out/language-server/MSBuildProjectTools.LanguageServer.Host.dll" --probe

You should see more information about what's going wrong with the discovery process (turns out a previous refactoring effort meant that the logger used during discovery was no longer being populated).

@stijnherreman
Copy link
Author

stijnherreman commented Aug 30, 2022

I rebuilt the container and had the original error again. Then when running that command, the first attempt succeeds, but next attempts all fail.

root@5ad4bc586244:/workspaces/myproject# MSBUILD_PROJECT_TOOLS_VERBOSE_LOGGING=1 MSBUILD_PROJECT_TOOLS_LOGGING_TO_STDERR=1 "/usr/bin/dotnet" "/root/.vscode-server/extensions/tintoy.msbuild-project-tools-0.4.7/out/language-server/MSBuildProjectTools.LanguageServer.Host.dll" --probe
[Debug/MSBuildDiscovery] Launching "dotnet --version"...
[Debug/MSBuildDiscovery] Launched "dotnet --version". Waiting for process 800 to terminate...
[Debug/MSBuildDiscovery] "dotnet --version" terminated with exit code 0.
[Debug/MSBuildDiscovery] "dotnet --version" returned the following text on STDOUT / STDERR.

6.0.202



[Verbose/MSBuildDiscovery] Discovered .NET SDK v6.0.202.
[Verbose/MSBuildDiscovery] Using new SDK discovery logic because .NET SDK v6.0.202 is greater than or equal to the minimum required v6 SDK version (v6.0.101).
[Debug/MSBuildDiscovery] Launching "dotnet --list-sdks"...
[Debug/MSBuildDiscovery] Launched "dotnet --list-sdks". Waiting for process 818 to terminate...
[Debug/MSBuildDiscovery] "dotnet --list-sdks" terminated with exit code 0.
[Debug/MSBuildDiscovery] {Command} returned no output on STDOUT / STDERR.
[Error/MSBuildDiscovery] Cannot find SDK v"6.0.202" via 'dotnet --list-sdks'.
[Debug/MSBuildDiscovery] Launching "dotnet --list-runtimes"...
[Debug/MSBuildDiscovery] Launched "dotnet --list-runtimes". Waiting for process 821 to terminate...
[Debug/MSBuildDiscovery] "dotnet --list-runtimes" terminated with exit code 0.
[Debug/MSBuildDiscovery] "dotnet --list-runtimes" returned the following text on STDOUT / STDERR.

Microsoft.AspNetCore.App 6.0.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]



[Verbose/MSBuildDiscovery] .NET host runtime is v6.0.4 ("Microsoft.NETCore.App").
[Verbose/] Logger initialised.
[Debug/] Creating language server...
[Debug/] Waiting for client to initialise language server...
PROBE: Yes, the language server can start.
root@5ad4bc586244:/workspaces/myproject# MSBUILD_PROJECT_TOOLS_VERBOSE_LOGGING=1 MSBUILD_PROJECT_TOOLS_LOGGING_TO_STDERR=1 "/usr/bin/dotnet" "/root/.vscode-server/extensions/tintoy.msbuild-project-tools-0.4.7/out/language-server/MSBuildProjectTools.LanguageServer.Host.dll" --probe
[Debug/MSBuildDiscovery] Launching "dotnet --version"...
[Debug/MSBuildDiscovery] Launched "dotnet --version". Waiting for process 963 to terminate...
[Debug/MSBuildDiscovery] "dotnet --version" terminated with exit code 0.
[Debug/MSBuildDiscovery] {Command} returned no output on STDOUT / STDERR.
System.InvalidOperationException: The 'dotnet --version' command did not return any output.
   at MSBuildProjectTools.LanguageServer.Utilities.DotNetRuntimeInfo.ParseDotNetVersionOutput(TextReader dotnetVersionOutput) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\DotNetRuntimeInfo.cs:line 147
   at MSBuildProjectTools.LanguageServer.Utilities.DotNetRuntimeInfo.GetCurrent(String baseDirectory, ILogger logger) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\DotNetRuntimeInfo.cs:line 69
   at MSBuildProjectTools.LanguageServer.Utilities.MSBuildHelper.DiscoverMSBuildEngine(String baseDirectory, ILogger logger) in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer.Common\Utilities\MSBuildHelper.cs:line 96
   at MSBuildProjectTools.LanguageServer.Program.Main() in D:\Development\github\tintoy\msbuild-project-tools-vscode\lib\server\src\LanguageServer\Program.cs:line 46

@stijnherreman
Copy link
Author

Just had another attempt succeed, without doing anything after the failed attempts.

root@5ad4bc586244:/workspaces/myproject# MSBUILD_PROJECT_TOOLS_VERBOSE_LOGGING=1 MSBUILD_PROJECT_TOOLS_LOGGING_TO_STDERR=1 "/usr/bin/dotnet" "/root/.vscode-server/extensions/tintoy.msbuild-project-tools-0.4.7/out/language-server/MSBuildProjectTools.LanguageServer.Host.dll" --probe
[Debug/MSBuildDiscovery] Launching "dotnet --version"...
[Debug/MSBuildDiscovery] Launched "dotnet --version". Waiting for process 3092 to terminate...
[Debug/MSBuildDiscovery] "dotnet --version" terminated with exit code 0.
[Debug/MSBuildDiscovery] "dotnet --version" returned the following text on STDOUT / STDERR.

6.0.202


[Verbose/MSBuildDiscovery] Discovered .NET SDK v6.0.202.
[Verbose/MSBuildDiscovery] Using new SDK discovery logic because .NET SDK v6.0.202 is greater than or equal to the minimum required v6 SDK version (v6.0.101).
[Debug/MSBuildDiscovery] Launching "dotnet --list-sdks"...
[Debug/MSBuildDiscovery] Launched "dotnet --list-sdks". Waiting for process 3111 to terminate...
[Debug/MSBuildDiscovery] "dotnet --list-sdks" terminated with exit code 0.
[Debug/MSBuildDiscovery] "dotnet --list-sdks" returned the following text on STDOUT / STDERR.

6.0.202 [/usr/share/dotnet/sdk]



[Verbose/MSBuildDiscovery] Target .NET SDK is v6.0.202 in "/usr/share/dotnet/sdk/6.0.202".
[Debug/MSBuildDiscovery] Launching "dotnet --list-runtimes"...
[Debug/MSBuildDiscovery] Launched "dotnet --list-runtimes". Waiting for process 3112 to terminate...
[Debug/MSBuildDiscovery] "dotnet --list-runtimes" terminated with exit code 0.
[Debug/MSBuildDiscovery] "dotnet --list-runtimes" returned the following text on STDOUT / STDERR.

Microsoft.AspNetCore.App 6.0.4 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.4 [/usr/share/dotnet/shared/Microsoft.NETCore.App]



[Verbose/MSBuildDiscovery] .NET host runtime is v6.0.4 ("Microsoft.NETCore.App").
[Verbose/] Logger initialised.
[Debug/] Creating language server...
[Debug/] Waiting for client to initialise language server...
PROBE: Yes, the language server can start.

@stijnherreman
Copy link
Author

I've just caught up with tintoy/msbuild-project-tools-vscode#105 and gave v0.4.9 a try. The bug seems to be fixed, I cannot reproduce it any more :)

@tintoy
Copy link
Owner

tintoy commented Sep 1, 2022

Good to hear - thanks for reporting (and being willing to try it out)!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants