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

"Compilation options cannot be null for C#/VB project" when running in Codespaces #6356

Closed
mattleibow opened this issue Sep 13, 2023 · 6 comments · Fixed by dotnet/roslyn#70496
Assignees
Milestone

Comments

@mattleibow
Copy link
Member

Environment data

dotnet --info output:

.NET SDK:
 Version:   7.0.306
 Commit:    f500069cb7

Runtime Environment:
 OS Name:     debian
 OS Version:  11
 OS Platform: Linux
 RID:         debian.11-x64
 Base Path:   /usr/share/dotnet/sdk/7.0.306/

Host:
  Version:      7.0.9
  Architecture: x64
  Commit:       8e9a17b221

.NET SDKs installed:
  7.0.306 [/usr/share/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.9 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.9 [/usr/share/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

VS Code version:

Version: 1.82.1
Commit: 6509174151d557a81c9d0b5f8a5a1e9274db5585
Date: 2023-09-08T08:41:47.631Z (5 days ago)
Browser: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36 Edg/116.0.1938.76

C# Extension version: v2.1.2

OmniSharp log

[Info  - 11:13:14 AM] Shutting down
Using dotnet configured on PATH
Dotnet path: /usr/share/dotnet/dotnet
Activating C# standalone...
[Info  - 11:13:18 AM] [Program]Language server initialized
[Info  - 11:13:18 AM] [LanguageServerProjectSystem]Loaded MSBuild at /usr/share/dotnet/sdk/7.0.306
[Info  - 11:13:18 AM] [LanguageServerProjectSystem]Loading /workspaces/SkiaSharp/tests/SkiaSharp.Tests.Console.sln...
[Error - 11:13:19 AM] [LanguageServerProjectSystem]Exception thrown while loading /workspaces/SkiaSharp/tests/SkiaSharp.Vulkan.Tests.Console/SkiaSharp.Vulkan.Tests.Console.csproj System.InvalidOperationException: Compilation options cannot be null for C#/VB project - line 147
   at Roslyn.Utilities.Contract.Fail(String message, Int32 lineNumber) in /_/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/Contract.cs:line 154
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LoadedProject.UpdateWithNewProjectInfoAsync(ProjectFileInfo newProjectInfo) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs:line 147
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LoadedProject.UpdateWithNewProjectInfoAsync(ProjectFileInfo newProjectInfo) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs:line 149
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, ProjectBuildManager projectBuildManager, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 275
[Error - 11:13:19 AM] [LanguageServerProjectSystem]Exception thrown while loading /workspaces/SkiaSharp/tests/SkiaSharp.Tests.Console/SkiaSharp.Tests.Console.csproj System.InvalidOperationException: Compilation options cannot be null for C#/VB project - line 147
   at Roslyn.Utilities.Contract.Fail(String message, Int32 lineNumber) in /_/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/Contract.cs:line 154
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LoadedProject.UpdateWithNewProjectInfoAsync(ProjectFileInfo newProjectInfo) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs:line 147
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LoadedProject.UpdateWithNewProjectInfoAsync(ProjectFileInfo newProjectInfo) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs:line 149
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, ProjectBuildManager projectBuildManager, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 275
[Error - 11:13:23 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.Skottie/SkiaSharp.Skottie.csproj: Project does not contain 'Compile' target.
[Error - 11:13:23 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.Skottie/SkiaSharp.Skottie.csproj: Project does not contain 'Compile' target.
[Error - 11:13:23 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.Skottie/SkiaSharp.Skottie.csproj: Project does not contain 'Compile' target.
[Error - 11:13:23 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.SceneGraph/SkiaSharp.SceneGraph.csproj: Project does not contain 'Compile' target.
[Error - 11:13:23 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.SceneGraph/SkiaSharp.SceneGraph.csproj: Project does not contain 'Compile' target.
[Error - 11:13:23 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.SceneGraph/SkiaSharp.SceneGraph.csproj: Project does not contain 'Compile' target.
[Error - 11:13:23 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/source/SkiaSharp.Vulkan/SkiaSharp.Vulkan.SharpVk/SkiaSharp.Vulkan.SharpVk.csproj: Project does not contain 'Compile' target.
[Error - 11:13:23 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.csproj: Project does not contain 'Compile' target.
[Error - 11:13:23 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/HarfBuzzSharp/HarfBuzzSharp.csproj: Project does not contain 'Compile' target.
[Error - 11:13:23 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/HarfBuzzSharp/HarfBuzzSharp.csproj: Project does not contain 'Compile' target.
[Error - 11:13:23 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/HarfBuzzSharp/HarfBuzzSharp.csproj: Project does not contain 'Compile' target.
[Error - 11:13:24 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp/SkiaSharp.csproj: Project does not contain 'Compile' target.
[Error - 11:13:24 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp/SkiaSharp.csproj: Project does not contain 'Compile' target.
[Error - 11:13:24 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp/SkiaSharp.csproj: Project does not contain 'Compile' target.
[Info  - 11:13:24 AM] [LanguageServerProjectSystem]Completed (re)load of all projects in 00:00:05.2977626
[Error - 11:16:15 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/HarfBuzzSharp/HarfBuzzSharp.csproj: Project does not contain 'Compile' target.
[Error - 11:16:15 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/HarfBuzzSharp/HarfBuzzSharp.csproj: Project does not contain 'Compile' target.
[Error - 11:16:15 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/HarfBuzzSharp/HarfBuzzSharp.csproj: Project does not contain 'Compile' target.
[Error - 11:16:15 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.Skottie/SkiaSharp.Skottie.csproj: Project does not contain 'Compile' target.
[Error - 11:16:15 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.Skottie/SkiaSharp.Skottie.csproj: Project does not contain 'Compile' target.
[Error - 11:16:15 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.Skottie/SkiaSharp.Skottie.csproj: Project does not contain 'Compile' target.
[Error - 11:16:16 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.SceneGraph/SkiaSharp.SceneGraph.csproj: Project does not contain 'Compile' target.
[Error - 11:16:16 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.SceneGraph/SkiaSharp.SceneGraph.csproj: Project does not contain 'Compile' target.
[Error - 11:16:16 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp.SceneGraph/SkiaSharp.SceneGraph.csproj: Project does not contain 'Compile' target.
[Info  - 11:16:16 AM] [LanguageServerProjectSystem]Completed (re)load of all projects in 00:00:01.9006472
[Error - 11:16:20 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp/SkiaSharp.csproj: Project does not contain 'Compile' target.
[Error - 11:16:20 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp/SkiaSharp.csproj: Project does not contain 'Compile' target.
[Error - 11:16:20 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/binding/SkiaSharp/SkiaSharp.csproj: Project does not contain 'Compile' target.
[Info  - 11:16:20 AM] [LanguageServerProjectSystem]Completed (re)load of all projects in 00:00:00.6730928
[Error - 11:16:20 AM] [LanguageServerProjectSystem]Exception thrown while loading /workspaces/SkiaSharp/tests/SkiaSharp.Tests.Console/SkiaSharp.Tests.Console.csproj System.InvalidOperationException: Compilation options cannot be null for C#/VB project - line 147
   at Roslyn.Utilities.Contract.Fail(String message, Int32 lineNumber) in /_/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/Contract.cs:line 154
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LoadedProject.UpdateWithNewProjectInfoAsync(ProjectFileInfo newProjectInfo) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs:line 173
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LoadedProject.UpdateWithNewProjectInfoAsync(ProjectFileInfo newProjectInfo) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs:line 173
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, ProjectBuildManager projectBuildManager, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 258
[Error - 11:16:20 AM] [LanguageServerProjectSystem]Exception thrown while loading /workspaces/SkiaSharp/tests/SkiaSharp.Vulkan.Tests.Console/SkiaSharp.Vulkan.Tests.Console.csproj System.InvalidOperationException: Compilation options cannot be null for C#/VB project - line 147
   at Roslyn.Utilities.Contract.Fail(String message, Int32 lineNumber) in /_/src/Workspaces/SharedUtilitiesAndExtensions/Compiler/Core/Utilities/Contract.cs:line 154
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LoadedProject.UpdateWithNewProjectInfoAsync(ProjectFileInfo newProjectInfo) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs:line 173
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LoadedProject.UpdateWithNewProjectInfoAsync(ProjectFileInfo newProjectInfo) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LoadedProject.cs:line 173
   at Microsoft.CodeAnalysis.LanguageServer.HostWorkspace.LanguageServerProjectSystem.LoadOrReloadProjectAsync(ProjectToLoad projectToLoad, ProjectBuildManager projectBuildManager, CancellationToken cancellationToken) in /_/src/Features/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/HostWorkspace/LanguageServerProjectSystem.cs:line 258
[Error - 11:16:21 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/source/SkiaSharp.Vulkan/SkiaSharp.Vulkan.SharpVk/SkiaSharp.Vulkan.SharpVk.csproj: Project does not contain 'Compile' target.
[Error - 11:16:21 AM] [LanguageServerProjectSystem]Failure while loading /workspaces/SkiaSharp/source/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz/SkiaSharp.HarfBuzz.csproj: Project does not contain 'Compile' target.
[Info  - 11:16:21 AM] [LanguageServerProjectSystem]Completed (re)load of all projects in 00:00:00.9401425

Steps to reproduce

  1. Open a codespace to this branch and wait for the things to init Set up dev containers mono/SkiaSharp#2605
  2. Open the tests solution: tests/SkiaSharp.Tests.Console.sln
  3. Observe it all falls apart
  4. Try running dotnet build tests/SkiaSharp.Tests.Console.sln
  5. That works, so it is the extensions that is sad

Expected behavior

The solution should open

Actual behavior

Fails to open

Additional context

Add any other context about the problem here.

@mattleibow mattleibow changed the title "Compilation options cannot be null for C#/VB project" when running in dev containers "Compilation options cannot be null for C#/VB project" when running in Codespaces Sep 13, 2023
@mattleibow
Copy link
Member Author

I just tried with mcr.microsoft.com/devcontainers/dotnet:dev-7.0 and I get 7.0.401 - srtill no loading supported. 😭

@mattleibow
Copy link
Member Author

C# Dev kit seems to have no issues...

Starting Spawn .NET server...
Using preinstalled .NET runtime at "/usr/share/dotnet/dotnet"
.NET server started and IPC established in 3531ms
Completed Spawn .NET server (3815ms)
Starting Open a solution...
Starting Open a solution with environment service...
Starting Clear environment...
Completed Clear environment (13ms)
Completed Open a solution with environment service (506ms)
Starting Restore solution...
Completed Open a solution (1774ms)
Starting NuGet restore for the solution.
Starting command: "dotnet" restore /workspaces/SkiaSharp/tests/SkiaSharp.Tests.Console.sln --interactive...
Completed command: "dotnet" restore /workspaces/SkiaSharp/tests/SkiaSharp.Tests.Console.sln --interactive (80590ms)
Completed NuGet restore.
Completed Restore solution (80593ms)

@rledyard-sdi
Copy link

I am getting the same error. My project file has not changed. Just started showing up this morning. Extension version is 2.1.2,

@BanMengma
Copy link

Have a similar issue when I work on my Unity project. Solved by following this link https://forum.unity.com/threads/microsoft-previews-unity-extension-for-visual-studio-code.1468913/. Update the Visual Stuidio Editor in Unity to newest version. So if you are in the Unity project and facing the issue in this topic, try this and hope it can help you. Gook luck. 8)

@dibarbet
Copy link
Member

dibarbet commented Oct 19, 2023

The missing compile target error log is tracked by #5786

The compilation options error seems to be suppressing a much wider range of project loading issues, fixing that in dotnet/roslyn#70467

The 'real' project load issue in SkiaSharp is

[Error - 3:23:42 PM] [LanguageServerProjectSystem] Failure while loading /home/dibarbet/source/repos/SkiaSharp/tests/SkiaSharp.Vulkan.Tests.Console/SkiaSharp.Vulkan.Tests.Console.csproj: The expression "[MSBuild]::VersionEquals('', 6.0)" cannot be evaluated. Version string was not in a correct format.  /home/dibarbet/source/repos/SkiaSharp/binding/IncludeNativeAssets.SkiaSharp.targets

Currently digging into what is going on there.

@dibarbet
Copy link
Member

The 'real' project load issue in SkiaSharp is

[Error - 3:23:42 PM] [LanguageServerProjectSystem] Failure while loading /home/dibarbet/source/repos/SkiaSharp/tests/SkiaSharp.Vulkan.Tests.Console/SkiaSharp.Vulkan.Tests.Console.csproj: The expression "[MSBuild]::VersionEquals('', 6.0)" cannot be evaluated. Version string was not in a correct format.  /home/dibarbet/source/repos/SkiaSharp/binding/IncludeNativeAssets.SkiaSharp.targets

Currently digging into what is going on there.

Issue is that the evaluation by default does not skip elements that evaluate to false, so it was hitting the VersionEquals check even though that whole item group is under a false condition.

Fix here - dotnet/roslyn#70496

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

Successfully merging a pull request may close this issue.

5 participants