我正在尝试在Visual Studio Code
C#
中启动一个非常小的初始项目。
我的操作系统是Ubuntu-18.04
我有节点版本v12.15.0
npm
版本6.13.4
可视代码版本1.42.0
我已经安装了sudo apt-get install dotnet-sdk-3.1
,并且安装成功。安装过程来自offical instructions for Ubuntu-18.04
1)wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
2)如下安装:
sudo add-apt-repository universe
sudo apt-get update
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-3.1
这是下面dotnet --info
的结果:
emanuele@pc:~$ dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 3.1.102
Commit: 573d158fea
Runtime Environment:
OS Name: ubuntu
OS Version: 18.04
OS Platform: Linux
RID: ubuntu.18.04-x64
Base Path: /usr/share/dotnet/sdk/3.1.102/
Host (useful for support):
Version: 3.1.2
Commit: 916b5cba26
.NET Core SDKs installed:
3.1.102 [/usr/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.2 [/usr/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.2 [/usr/share/dotnet/shared/Microsoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
安装成功作为最终结果。
我继续使用Visual Studio,并输入以下内容创建了一个新项目:
1)sudo npm install -g yo bower grunt-cli gulp generator-aspnet
2)yo aspnet
并正确收到了如下所示的欢迎信息,并选择了 Web应用程序,因为我希望将来使用google-drive API
方法作为可应用程序:>
说明如下所示,但当我dotnet run
或sudo dotnet run
时,我收到以下消息:
如果有人要复制/粘贴,Iam也会报告:
A compatible installed .NET Core SDK for global.json version [1.0.0-rc4-004771] from [/home/emanuele/Desktop/dredge-doc/dredge-doc/global.json] was not found
Install the [1.0.0-rc4-004771] .NET Core SDK or update [/home/emanuele/Desktop/dredge-doc/dredge-doc/global.json] with an installed .NET Core SDK:
3.1.102 [/usr/share/dotnet/sdk]
以下是输出日志的结果:
Starting OmniSharp server at 2/21/2020, 10:15:31 AM
Target: /home/emanuele/Desktop/dredge-doc
OmniSharp server started.
Path: /home/emanuele/.vscode/extensions/ms-vscode.csharp-1.21.12/.omnisharp/1.34.13/run
PID: 13881
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on ubuntu 18.4 (x64)
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 1 MSBuild instance(s)
1: StandAlone 16.4 - "/home/emanuele/.vscode/extensions/ms-vscode.csharp-1.21.12/.omnisharp/1.34.13/omnisharp/.msbuild/Current/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
MSBUILD_EXE_PATH environment variable set to '/home/emanuele/.vscode/extensions/ms-vscode.csharp-1.21.12/.omnisharp/1.34.13/omnisharp/.msbuild/Current/Bin/MSBuild.dll'
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Registered MSBuild instance: StandAlone 16.4 - "/home/emanuele/.vscode/extensions/ms-vscode.csharp-1.21.12/.omnisharp/1.34.13/omnisharp/.msbuild/Current/Bin"
CscToolExe = csc.exe
MSBuildToolsPath = /home/emanuele/.vscode/extensions/ms-vscode.csharp-1.21.12/.omnisharp/1.34.13/omnisharp/.msbuild/Current/Bin
CscToolPath = /home/emanuele/.vscode/extensions/ms-vscode.csharp-1.21.12/.omnisharp/1.34.13/omnisharp/.msbuild/Current/Bin/Roslyn
BypassFrameworkInstallChecks = true
MSBuildExtensionsPath = /home/emanuele/.vscode/extensions/ms-vscode.csharp-1.21.12/.omnisharp/1.34.13/omnisharp/.msbuild
[info]: OmniSharp.Cake.CakeProjectSystem
Detecting Cake files in '/home/emanuele/Desktop/dredge-doc'.
[info]: OmniSharp.Cake.CakeProjectSystem
Could not find any Cake files
[info]: OmniSharp.MSBuild.ProjectSystem
No solution files found in '/home/emanuele/Desktop/dredge-doc'
[info]: OmniSharp.MSBuild.ProjectManager
Queue project update for '/home/emanuele/Desktop/dredge-doc/dredge-doc/dredge-doc.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
Detecting CSX files in '/home/emanuele/Desktop/dredge-doc'.
[info]: OmniSharp.Script.ScriptProjectSystem
Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
[info]: OmniSharp.WorkspaceInitializer
Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.EditorConfigWorkspaceOptionsProvider, Order: 200
[info]: OmniSharp.WorkspaceInitializer
Configuration finished.
[info]: OmniSharp.Stdio.Host
Omnisharp server running using Stdio at location '/home/emanuele/Desktop/dredge-doc' on host 12704.
[info]: OmniSharp.MSBuild.ProjectManager
Loading project: /home/emanuele/Desktop/dredge-doc/dredge-doc/dredge-doc.csproj
A compatible installed .NET Core SDK for global.json version [1.0.0-rc4-004771] from [/home/emanuele/Desktop/dredge-doc/dredge-doc/global.json] was not found
Install the [1.0.0-rc4-004771] .NET Core SDK or update [/home/emanuele/Desktop/dredge-doc/dredge-doc/global.json] with an installed .NET Core SDK:
[warn]: OmniSharp.MSBuild.ProjectManager
Failed to load project file '/home/emanuele/Desktop/dredge-doc/dredge-doc/dredge-doc.csproj'.
/home/emanuele/Desktop/dredge-doc/dredge-doc/dredge-doc.csproj(1,1)
Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. /home/emanuele/Desktop/dredge-doc/dredge-doc/dredge-doc.csproj
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject (System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, System.Object[] args) [0x00040] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.VerifyThrowInvalidProject[T1] (System.Boolean condition, System.String errorSubCategoryResourceName, Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00003] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1] (Microsoft.Build.Shared.IElementLocation elementLocation, System.String resourceName, T1 arg0) [0x00000] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImportsFromUnescapedImportExpressionConditioned (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, System.Collections.Generic.List`1[Microsoft.Build.Construction.ProjectRootElement]& projects, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult, System.Boolean throwOnFileNotExistsError) [0x00254] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].ExpandAndLoadImports (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement, Microsoft.Build.BackEnd.SdkResolution.SdkResult& sdkResult) [0x00027] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].EvaluateImportElement (System.String directoryOfImportingFile, Microsoft.Build.Construction.ProjectImportElement importElement) [0x0000d] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].PerformDepthFirstPass (Microsoft.Build.Construction.ProjectRootElement currentProjectOrImport) [0x000e6] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Framework.BuildEventContext buildEventContext) [0x0014c] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Evaluator`4[P,I,M,D].Evaluate (Microsoft.Build.Evaluation.IEvaluatorData`4[P,I,M,D] data, Microsoft.Build.Construction.ProjectRootElement root, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, System.Int32 maxNodeCount, Microsoft.Build.Collections.PropertyDictionary`1[T] environmentProperties, Microsoft.Build.BackEnd.Logging.ILoggingService loggingService, Microsoft.Build.Evaluation.IItemFactory`2[S,T] itemFactory, Microsoft.Build.Evaluation.IToolsetProvider toolsetProvider, Microsoft.Build.Evaluation.ProjectRootElementCacheBase projectRootElementCache, Microsoft.Build.Framework.BuildEventContext buildEventContext, Microsoft.Build.BackEnd.SdkResolution.ISdkResolverService sdkResolverService, System.Int32 submissionId, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext, System.Boolean interactive) [0x00044] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.Reevaluate (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00063] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00035] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.BackEnd.Logging.ILoggingService loggingServiceForEvaluation, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00000] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.ReevaluateIfNecessary (Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00007] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Project+ProjectImpl.Initialize (System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x0012b] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings, Microsoft.Build.Evaluation.Context.EvaluationContext evaluationContext) [0x00075] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, System.String subToolsetVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection, Microsoft.Build.Evaluation.ProjectLoadSettings loadSettings) [0x00000] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.Project..ctor (System.String projectFile, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion, Microsoft.Build.Evaluation.ProjectCollection projectCollection) [0x00000] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.Collections.Generic.IDictionary`2[TKey,TValue] globalProperties, System.String toolsVersion) [0x000f7] in <d7593966a5ec48e0baa47768c52e35a5>:0
at Microsoft.Build.Evaluation.ProjectCollection.LoadProject (System.String fileName, System.String toolsVersion) [0x00000] in <d7593966a5ec48e0baa47768c52e35a5>:0
at OmniSharp.MSBuild.ProjectLoader.EvaluateProjectFileCore (System.String filePath) [0x0003f] in <274bc1b8e17a461caeeca97c1d1fc005>:0
at OmniSharp.MSBuild.ProjectLoader.BuildProject (System.String filePath) [0x0000d] in <274bc1b8e17a461caeeca97c1d1fc005>:0
at OmniSharp.MSBuild.ProjectFile.ProjectFileInfo.Load (System.String filePath, OmniSharp.MSBuild.ProjectIdInfo projectIdInfo, OmniSharp.MSBuild.ProjectLoader loader) [0x00015] in <274bc1b8e17a461caeeca97c1d1fc005>:0
at OmniSharp.MSBuild.ProjectManager+<>c__DisplayClass29_0.<LoadProject>b__0 () [0x00000] in <274bc1b8e17a461caeeca97c1d1fc005>:0
at (wrapper delegate-invoke) System.Func`1[System.ValueTuple`3[OmniSharp.MSBuild.ProjectFile.ProjectFileInfo,System.Collections.Immutable.ImmutableArray`1[OmniSharp.MSBuild.Logging.MSBuildDiagnostic],OmniSharp.MSBuild.Notification.ProjectLoadedEventArgs]].invoke_TResult()
at OmniSharp.MSBuild.ProjectManager.LoadOrReloadProject (System.String projectFilePath, System.Func`1[TResult] loader) [0x0001b] in <274bc1b8e17a461caeeca97c1d1fc005>:0
[fail]: OmniSharp.MSBuild.ProjectManager
Attempted to update project that is not loaded: /home/emanuele/Desktop/dredge-doc/dredge-doc/dredge-doc.csproj
我用来帮助我解决问题的帖子是:
1)fail-omnisharp-msbuild-projectmanager
2)this one,因为我的操作系统也是Ubuntu-18.04
,但是在我看来这不是可行的解决方案,因为它需要手动安装文件。我不确定这是正确的程序。
3)This is useful但是用户使用Windows,所以我不确定这是否也是可修复的解决方案
如果有人遇到与我相同的问题,感谢您提供解决此问题的指导。