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

Failed to load project file: NullReferenceException #3341

Closed
Ratismal opened this issue Oct 12, 2019 · 4 comments
Closed

Failed to load project file: NullReferenceException #3341

Ratismal opened this issue Oct 12, 2019 · 4 comments

Comments

@Ratismal
Copy link

Ratismal commented Oct 12, 2019

Environment data

dotnet --info output:

.NET Core SDK (reflecting any global.json):
 Version:   3.0.100
 Commit:    04339c3a26

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.17763
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\3.0.100\

Host (useful for support):
  Version: 3.0.0
  Commit:  7d57652f33

.NET Core SDKs installed:
  1.1.0 [C:\Program Files\dotnet\sdk]
  2.0.0 [C:\Program Files\dotnet\sdk]
  2.0.2 [C:\Program Files\dotnet\sdk]
  2.0.3 [C:\Program Files\dotnet\sdk]
  3.0.100 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
  Microsoft.AspNetCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.0.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

VS Code version: 1.39.1
C# Extension version: 1.21.4

Steps to reproduce

I'm trying to use VSCode to load a Unity project. I'm not sure about any specific reproduction steps, as the same project works fine on another machine.

Expected behavior

Omnisharp should load the project.

Actual behavior

Omnisharp fails with this error:

[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'd:\game\Assembly-CSharp.csproj'.
d:\game\Assembly-CSharp.csproj(1,1)
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Build.Shared.BuildEnvironmentHelper.get_Instance()
   at Microsoft.Build.Utilities.Traits.get_Instance()
   at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly)
   at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties)
   at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectLoader.cs:line 123
   at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectLoader.cs:line 72
   at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectIdInfo projectIdInfo, ProjectLoader loader) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectFile\ProjectFileInfo.cs:line 98
   at OmniSharp.MSBuild.ProjectManager.<>c__DisplayClass29_0.<LoadProject>b__0() in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 297
   at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 308

[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: d:\game\Assembly-CSharp-firstpass.csproj
[warn]: OmniSharp.MSBuild.ProjectManager
        Failed to load project file 'd:\game\Assembly-CSharp-firstpass.csproj'.
d:\game\Assembly-CSharp-firstpass.csproj(1,1)
System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.Build.Shared.BuildEnvironmentHelper.get_Instance()
   at Microsoft.Build.Utilities.Traits.get_Instance()
   at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties, IEnumerable`1 loggers, IEnumerable`1 remoteLoggers, ToolsetDefinitionLocations toolsetDefinitionLocations, Int32 maxNodeCount, Boolean onlyLogCriticalEvents, Boolean loadProjectsReadOnly)
   at Microsoft.Build.Evaluation.ProjectCollection..ctor(IDictionary`2 globalProperties)
   at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore(String filePath) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectLoader.cs:line 123
   at OmniSharp.MSBuild.ProjectLoader.BuildProject(String filePath) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectLoader.cs:line 72
   at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load(String filePath, ProjectIdInfo projectIdInfo, ProjectLoader loader) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectFile\ProjectFileInfo.cs:line 98
   at OmniSharp.MSBuild.ProjectManager.<>c__DisplayClass29_0.<LoadProject>b__0() in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 297
   at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject(String projectFilePath, Func`1 loader) in D:\a\1\s\src\OmniSharp.MSBuild\ProjectManager.cs:line 308
[omnisharp.log](https://github.com/OmniSharp/omnisharp-vscode/files/3720119/omnisharp.log)

I've attached the full log:
omnisharp.log

Solutions attempted

I've reinstalled:

  • dotnet
  • mono
  • c# extension
  • visual studio (now using 2019)

I've tried

Any help would be appreciated, as I've been trying to figure this out for hours.

@filipw
Copy link
Contributor

filipw commented Oct 14, 2019

can you share this project?

  • visual studio (now using 2019)

according to the log you provided, there is no Visual Studio 2019 available on the machine? you could try installing Build Tools for VS2019 https://visualstudio.microsoft.com/downloads/#build-tools-for-visual-studio-2019

@Ratismal
Copy link
Author

@filipw Thanks for the response.

I've reinstalled Build Tools for VS2019, but it hasn't made any difference.

I created a new dotnet project with dotnet new console --name testproj. This issue happens on it for me. Repository (including an omnisharp log file) here: https://github.com/Ratismal/omnisharp_testproj

@filipw
Copy link
Contributor

filipw commented Oct 16, 2019

@nguerrera do you have any idea? https://github.com/Ratismal/omnisharp_testproj/blob/master/omnisharp.log
it fails with MSBuild tools for vs2019 too, with some internal MSBuild exception. Is this something for the SDK team or should we open a bug in MSBuild repo?

@Ratismal
Copy link
Author

Just an update, I've completely reinstalled my computer and this problem no longer occurs. I'm going to close this issue because I think it was likely related to something in my previous windows installation. Feel free to reopen if you think this isn't the case, but I won't be able to provide any more information.

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

3 participants