An API to locate MSBuild assemblies from an installed Visual Studio location. Use this to ensure that calling the MSBuild API will use the same toolset that a build from Visual Studio or msbuild.exe would.
Other
218
stars
83
forks
source link
QueryVisualStudioInstances() fails with NullReferenceException when VSINSTALLDIR is set #65
When the VSINSTALLDIR environment variable is set even though the tool is not running from a Developer command prompt, QueryVisualStudioInstances() fails with a NullReferenceException.
Stacktrace:
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Build.Locator.VisualStudioInstance..ctor(String name, String path, Version version, DiscoveryType discoveryType)
at Microsoft.Build.Locator.MSBuildLocator.GetDevConsoleInstance()
at Microsoft.Build.Locator.MSBuildLocator.<GetInstances>d__20.MoveNext()
at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
at System.Linq.Enumerable.Any[TSource](IEnumerable`1 source, Func`2 predicate)
Looking at the code, I guess there is a version != null check missing in GetDevConsoleInstance
This also happens when DiscoveryTypes is set to DiscoveryType.VisualStudioSetup only
When the
VSINSTALLDIR
environment variable is set even though the tool is not running from a Developer command prompt, QueryVisualStudioInstances() fails with a NullReferenceException.Stacktrace:
Looking at the code, I guess there is a
version != null
check missing in GetDevConsoleInstanceThis also happens when
DiscoveryTypes
is set toDiscoveryType.VisualStudioSetup
only