mono / monodevelop

MonoDevelop is a cross platform .NET IDE
http://www.monodevelop.com
2.84k stars 1.02k forks source link

DotNetCliToolReference fails in VS for Mac #9050

Open daniel-white opened 5 years ago

daniel-white commented 5 years ago

Steps to reproduce

* Build with VS for Mac
* Build from terminal (`dotnet build`)

## Expected  behavior
The swagger tool is run as it does from the CLI.

## Actual behavior
Fails to find tool in mac

dotnet -d swagger Telemetry is: Enabled projectfactory: MSBUILD_EXE_PATH = /Users/daniel.white/Library/Caches/VisualStudio/8.0/MSBuild/887671/MonoDevelop.MSBuildBuilder.exe projectfactory: MSBuild project path = /Users/daniel.white/Builds/foo/foo.csproj Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK resolver type "DotNetMSBuildSdkResolver" failed to load. The type initializer for 'Microsoft.DotNet.MSBuildSdkResolver.VSSettings' threw an exception. /Users/daniel.white/Builds/foo/foo.csproj ---> System.TypeInitializationException: The type initializer for 'Microsoft.DotNet.MSBuildSdkResolver.VSSettings' threw an exception. ---> System.TypeInitializationException: The type initializer for 'Microsoft.DotNet.MSBuildSdkResolver.Interop' threw an exception. ---> System.TypeLoadException: Could not load type 'System.Runtime.InteropServices.OSPlatform' from assembly 'mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. --- End of inner exception stack trace --- at Microsoft.DotNet.MSBuildSdkResolver.VSSettings..ctor() in //src/Microsoft.DotNet.MSBuildSdkResolver/VSSettings.cs:line 30 at Microsoft.DotNet.MSBuildSdkResolver.VSSettings..cctor() in //src/Microsoft.DotNet.MSBuildSdkResolver/VSSettings.cs:line 25 Microsoft.DotNet.Cli.Utils.CommandUnknownException: No executable found matching command "dotnet-swagger" at Microsoft.DotNet.Cli.Utils.Command.Create(ICommandResolverPolicy commandResolverPolicy, String commandName, IEnumerable1 args, NuGetFramework framework, String configuration, String outputPath, String applicationName) at Microsoft.DotNet.Cli.Utils.Command.Create(String commandName, IEnumerable1 args, NuGetFramework framework, String configuration, String outputPath, String applicationName) at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient) at Microsoft.DotNet.Cli.Program.Main(String[] args) --- End of inner exception stack trace --- at Microsoft.DotNet.MSBuildSdkResolver.DotNetMSBuildSdkResolver..ctor() in //src/Microsoft.DotNet.MSBuildSdkResolver/MSBuildSdkResolver.cs:line 38 --- End of inner exception stack trace --- at Microsoft.Build.Shared.ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(Boolean condition, String errorSubCategoryResourceName, BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args) at Microsoft.Build.Shared.ProjectFileErrorUtilities.ThrowInvalidProjectFile(BuildEventFileInfo projectFile, Exception innerException, String resourceName, Object[] args) at Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.LoadResolvers(String resolverPath, LoggingContext loggingContext, ElementLocation location, List1 resolvers) at Microsoft.Build.BackEnd.SdkResolution.SdkResolverLoader.LoadResolvers(LoggingContext loggingContext, ElementLocation location) at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.Initialize(LoggingContext loggingContext, ElementLocation location) at Microsoft.Build.BackEnd.SdkResolution.SdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive) at Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.<>c__DisplayClass3_0.<ResolveSdk>b__0(String key) at System.Collections.Concurrent.ConcurrentDictionary2.GetOrAdd(TKey key, Func2 valueFactory) at Microsoft.Build.BackEnd.SdkResolution.CachingSdkResolverService.ResolveSdk(Int32 submissionId, SdkReference sdk, LoggingContext loggingContext, ElementLocation sdkReferenceLocation, String solutionPath, String projectPath, Boolean interactive) at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError) at Microsoft.Build.Evaluation.Evaluator4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult) at Microsoft.Build.Evaluation.Evaluator4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement) at Microsoft.Build.Evaluation.Evaluator4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport) at Microsoft.Build.Evaluation.Evaluator4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext) at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project.Initialize(IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext) at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary2 globalProperties, String toolsVersion) at Microsoft.DotNet.Cli.Utils.MSBuildProject..ctor(String msBuildProjectPath, NuGetFramework framework, String configuration, String outputPath, String msBuildExePath) at Microsoft.DotNet.Cli.Utils.ProjectFactory.GetMSBuildProj(String projectDirectory, NuGetFramework framework, String configuration, String outputPath) projecttoolscommandresolver: ProjectFactory did not find Project. /Users/daniel.white/Builds/foo/foo.csproj(12,5): error MSB3073: The command "dotnet -d swagger" exited with code 1. Done building project "foo.csproj" -- FAILED.


## Environment data
`dotnet --info` output:
(from inside VS for Mac)

.NET Core SDK (reflecting any global.json): Version: 2.1.802 Commit: 177d0b2525

Runtime Environment: OS Name: Mac OS X OS Version: 10.14 OS Platform: Darwin RID: osx.10.14-x64 Base Path: /usr/local/share/dotnet/sdk/2.1.802/

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

.NET Core SDKs installed: 2.1.504 [/usr/local/share/dotnet/sdk] 2.1.802 [/usr/local/share/dotnet/sdk] 3.0.100 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.11 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.8 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.11 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.12 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.13 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.0.0 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

daniel-white commented 5 years ago

Cross posted: https://github.com/dotnet/cli/issues/12967

daniel-white commented 5 years ago

This still fails in .NET Core 3.0.100 SDK.

Target GenerateSwagger:
    dotnet -d swagger
    Telemetry is: Enabled
    projectfactory: MSBUILD_EXE_PATH = /Users/daniel.white/Library/Caches/VisualStudio/8.0/MSBuild/94437_1/MonoDevelop.MSBuildBuilder.exe
    projectfactory: MSBuild project path = /Users/daniel.white/Builds/foo/foo.csproj
    Microsoft.Build.Exceptions.InvalidProjectFileException: The imported project "/Users/daniel.white/Library/Caches/VisualStudio/8.0/MSBuild/94437_1/Current/Microsoft.Common.props" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.  /usr/local/share/dotnet/sdk/3.0.100/Sdks/Microsoft.NET.Sdk/Sdk/Sdk.props
       at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject(String errorSubCategoryResourceName, IElementLocation elementLocation, String resourceName, Object[] args)
       at Microsoft.Build.Shared.ProjectErrorUtilities.ThrowInvalidProject[T1](IElementLocation elementLocation, String resourceName, T1 arg0)
    Microsoft.DotNet.Cli.Utils.CommandUnknownException: Could not execute because the specified command or file was not found.
    Possible reasons for this include:
      * You misspelled a built-in dotnet command.
      * You intended to execute a .NET Core program, but dotnet-swagger does not exist.
      * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
       at Microsoft.DotNet.CommandFactory.CommandFactoryUsingResolver.Create(ICommandResolverPolicy commandResolverPolicy, String commandName, IEnumerable`1 args, NuGetFramework framework, String configuration, String outputPath, String applicationName)
       at Microsoft.DotNet.Cli.Program.ProcessArgs(String[] args, ITelemetry telemetryClient)
       at Microsoft.DotNet.Cli.Program.Main(String[] args)
       at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpression(String directoryOfImportingFile, ProjectImportElement importElement, String unescapedExpression, Boolean throwOnFileNotExistsError, List`1& imports)
       at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImportsFromUnescapedImportExpressionConditioned(String directoryOfImportingFile, ProjectImportElement importElement, List`1& projects, SdkResult& sdkResult, Boolean throwOnFileNotExistsError)
       at Microsoft.Build.Evaluation.Evaluator`4.ExpandAndLoadImports(String directoryOfImportingFile, ProjectImportElement importElement, SdkResult& sdkResult)
       at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
       at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
       at Microsoft.Build.Evaluation.Evaluator`4.EvaluateImportElement(String directoryOfImportingFile, ProjectImportElement importElement)
       at Microsoft.Build.Evaluation.Evaluator`4.PerformDepthFirstPass(ProjectRootElement currentProjectOrImport)
       at Microsoft.Build.Evaluation.Evaluator`4.Evaluate(ILoggingService loggingService, BuildEventContext buildEventContext)
       at Microsoft.Build.Evaluation.Project.Reevaluate(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
       at Microsoft.Build.Evaluation.Project.ReevaluateIfNecessary(ILoggingService loggingServiceForEvaluation, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
       at Microsoft.Build.Evaluation.Project.Initialize(IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
       at Microsoft.Build.Evaluation.Project..ctor(String projectFile, IDictionary`2 globalProperties, String toolsVersion, String subToolsetVersion, ProjectCollection projectCollection, ProjectLoadSettings loadSettings, EvaluationContext evaluationContext)
       at Microsoft.Build.Evaluation.ProjectCollection.LoadProject(String fileName, IDictionary`2 globalProperties, String toolsVersion)
       at Microsoft.DotNet.CommandFactory.MSBuildProject..ctor(String msBuildProjectPath, NuGetFramework framework, String configuration, String outputPath, String msBuildExePath)
       at Microsoft.DotNet.CommandFactory.ProjectFactory.GetMSBuildProj(String projectDirectory, NuGetFramework framework, String configuration, String outputPath)
    projecttoolscommandresolver: ProjectFactory did not find Project.
    /Users/daniel.white/Builds/foo/foo.csproj(12,5): error MSB3073: The command "dotnet -d swagger" exited with code 1.