mono / monodevelop

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

MSBuild resolver failing #4360

Closed mhutch closed 5 years ago

mhutch commented 6 years ago

When opening an SDK style project in VS for Mac, a number of the following errors are shown in the log:

ERROR [2018-03-28 19:22:06Z]: [MSBuild]
System.ArgumentNullException: Value cannot be null.
Parameter name: v1
  at System.Version.op_LessThan (System.Version v1, System.Version v2) [0x00003] in /Users/builder/jenkins/workspace/build-package-osx-mono/2017-12/external/bockbuild/builds/mono-x64/mcs/class/referencesource/mscorlib/system/version.cs:452 
  at Microsoft.DotNet.MSBuildSdkResolver.DotNetMSBuildSdkResolver.Resolve (Microsoft.Build.Framework.SdkReference sdkReference, Microsoft.Build.Framework.SdkResolverContext context, Microsoft.Build.Framework.SdkResultFactory factory) [0x000b7] in /Users/ankit/dev/cli/src/Microsoft.DotNet.MSBuildSdkResolver/MSBuildSdkResolver.cs:71 
  at MonoDevelop.Projects.MSBuild.SdkResolution.GetSdkPath (Microsoft.Build.Framework.SdkReference sdk, MonoDevelop.Projects.MSBuild.ILoggingService logger, MonoDevelop.Projects.MSBuild.MSBuildContext buildEventContext, System.String projectFile, System.String solutionPath) [0x00046] in /Users/builder/data/lanes/5965/ace1e107/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/SdkResolution.cs:63 

It looks like the SdkResolverContext passed to the Resolve method has a null MSBuildVersion value.

https://github.com/dotnet/cli/blob/master/src/Microsoft.DotNet.MSBuildSdkResolver/MSBuildSdkResolver.cs#L71 https://github.com/mono/monodevelop/blob/master/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.MSBuild/SdkResolution.cs#L60

VS bug #591632

wjk commented 6 years ago

đź‘Ť I've seen this too. In addition, VSMac does not apparently know about the NuGet-based SDK resolver (which was in the MSBuild repo, but seems to have been removed recently).

When I try to load a project using a custom SDK (in my case, MSBuild.Sdk.Extras), if I hardcode the package version into the <Project Sdk=""> element, I get the error dialog seen in #4342. If I instead move the version into a global.json file, the project appears in the Solution Explorer, but does not contain any content (no source files, no assembly references, nothing) and is therefore unusable. If I try to build it, it complains of a missing configuration. If I check Ide.log I still see a number of these exceptions appearing.