dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.84k stars 663 forks source link

Failing to load .csproj files after uninstalling visual studio 2017 #1954

Open Tyfyter opened 6 years ago

Tyfyter commented 6 years ago

Environment data

dotnet --info output:

.NET Command Line Tools (2.1.3)

Product Information:
 Version:            2.1.3
 Commit SHA-1 hash:  a0ca411ca5

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x64
 Base Path:   C:\Program Files\dotnet\sdk\2.1.3\

Microsoft .NET Core Shared Framework Host

  Version  : 2.0.4
  Build    : 7f262f453d8c8479b9af91d34c013b3aa05bc1ff

VS Code version:1.19 C# Extension version: current version as of 5:33 PM EST 1/7/2018

Steps to Reproduce: Unknown.

The omnisharp log contained this:

Starting OmniSharp server at 1/7/2018, 3:31:34 PM
Target: c:\Users\Tyfyter\Documents\My Games\Terraria\ModLoader\Mod Sources\elemental\elemental.sln

OmniSharp server started
Path: C:\Users\Tyfyter.vscode\extensions\ms-vscode.csharp-1.13.1.omnisharp\OmniSharp.exe
PID: 7556

Starting OmniSharp on Windows 6.1.7601.65536 (x64)
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 15.0 - "C:\Users\Tyfyter.vscode\extensions\ms-vscode.csharp-1.13.1.omnisharp\msbuild\15.0\Bin"
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to 'C:\Users\Tyfyter.vscode\extensions\ms-vscode.csharp-1.13.1.omnisharp\msbuild\15.0\Bin\MSBuild.exe'
info: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 15.0 - "C:\Users\Tyfyter.vscode\extensions\ms-vscode.csharp-1.13.1.omnisharp\msbuild\15.0\Bin"
CscToolExe = csc.exe
CscToolPath = C:\Users\Tyfyter.vscode\extensions\ms-vscode.csharp-1.13.1.omnisharp\msbuild\15.0\Bin\Roslyn
MSBuildExtensionsPath = C:\Users\Tyfyter.vscode\extensions\ms-vscode.csharp-1.13.1.omnisharp\msbuild
MSBuildToolsPath = C:\Users\Tyfyter.vscode\extensions\ms-vscode.csharp-1.13.1.omnisharp\msbuild\15.0\Bin
info: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in 'c:\Users\Tyfyter\Documents\My Games\Terraria\ModLoader\Mod Sources\elemental'.
info: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
info: OmniSharp.DotNet.DotNetProjectSystem
Initializing in c:\Users\Tyfyter\Documents\My Games\Terraria\ModLoader\Mod Sources\elemental
info: OmniSharp.DotNet.DotNetProjectSystem
Auto package restore: False
info: OmniSharp.DotNet.DotNetProjectSystem
Update workspace context
info: OmniSharp.DotNet.DotNetProjectSystem
Resolving projects references
info: OmniSharp.MSBuild.MSBuildProjectSystem
Detecting projects in 'c:\Users\Tyfyter\Documents\My Games\Terraria\ModLoader\Mod Sources\elemental\elemental.sln'.
info: OmniSharp.MSBuild.MSBuildProjectSystem
Loading project: c:\Users\Tyfyter\Documents\My Games\Terraria\ModLoader\Mod Sources\elemental\elemental.csproj
[fail]: OmniSharp.MSBuild.ProjectFile.ProjectFileInfo
The reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
[warn]: OmniSharp.MSBuild.MSBuildProjectSystem
Failed to load project file 'c:\Users\Tyfyter\Documents\My Games\Terraria\ModLoader\Mod Sources\elemental\elemental.csproj'.
c:\Users\Tyfyter\Documents\My Games\Terraria\ModLoader\Mod Sources\elemental\elemental.csproj

Detecting CSX files in 'c:\Users\Tyfyter\Documents\My Games\Terraria\ModLoader\Mod Sources\elemental'.
info: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
info: OmniSharp.Stdio.Host
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
info: OmniSharp.Stdio.Host
Configuration finished.
info: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location 'c:\Users\Tyfyter\Documents\My Games\Terraria\ModLoader\Mod Sources\elemental' on host 9000.

the .csproj file it was attempting (and failing) to open (elemental.csproj) contained this:
[elemental.csproj.txt](https://github.com/OmniSharp/omnisharp-vscode/files/1610269/elemental.csproj.txt)
rchande commented 6 years ago

@Tyfyter Do you still have the .NET 4.5.2 SDK installed? It sounds like you might have uninstalled it along with VS.

I ask based on this part of your log:

he reference assemblies for framework ".NETFramework,Version=v4.5.2" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
Tyfyter commented 6 years ago

@rchande I recently reinstalled it for an unrelated reason, however, visual studio code is still not loading the .csproj file properly. I may have installed a severely outdated version, as the only versions in the sdk folder are 2.1.3, and NuGetFallbackFolder, but for some reason when I tried to install .net 4.5.2 it said I already have it or a later version installed, and when checking my registry to verify this I saw that I seem to have .net version 4.7.02558 installed, how would I update the files to work with this?

Tyfyter commented 6 years ago

at this point I am entirely unsure of what .net version I have installed as the registry both says 4.7.02558 and 461310, but there are no folders for either of those or 4.7.1 while there is a folder for version 4.0.30319.

Tyfyter commented 6 years ago

I may have found the problem (which seems to be that my csproj file is set up for .net 4.5.2 but I have .net 4.7.1 installed), however, everything I've tried so far to fix it has failed:

Debug AnyCPU {8298EAB6-0586-4BDA-9483-83624B66B13A} Library Properties Light Light v4.5.2 512 true
kub1x commented 6 years ago

Hey, according to registers (using the net-version tool) I have .NET 4.7.1 installed. My project is aimed for .NET 4.6. I get the same output as @Tyfyter. When I did change following change:

-    <TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
+    <TargetFrameworkVersion>v4.7.1</TargetFrameworkVersion>

I get the same error for v4.7.1. Is it a problem with detecting the latest .NET version yet?

DustinCampbell commented 6 years ago

You'll want to install the developer pack for the target framework your project uses: https://github.com/dotnet/docs/blob/master/docs/framework/install/guide-for-developers.md.

These contain the necessary reference assemblies to handle your project.